在线法官犯错

Online Judge do mistake?

本文关键字:犯错 在线      更新时间:2023-10-16

well正如我一直说的那样,我是一个新的C++程序员当我解决简单的问题来剃除我的技能或你们所说的任何东西时......我面对这种不断发生的奇怪事情在线法官不断给我一个错误的答案......

现在要确定我做的一切都是正确的我调试并使用了许多输入,每次我都能获得正确的输出.

现在,我将为您提供一个简单的代码,该代码给我一个错误,其中包含包含描述的链接问题。

让我们从链接开始:http://www.urionlinejudge.com.br/repository/UOJ_1036_en.html现在的代码:

#include <cmath>
#include <iomanip>
#include <iostream>
void Formula(float v1, float v2, float b);
using namespace std;
int main(int argc, char **argv) {
    //making the variables ....
    float a, b, c;
    float v1, v2;
    //reading the variables
    cin >> a >> b >> c;
    //assign v1,v2
    v1 = (pow(b, 2) - (4 * a * c));
    v2 = 2 * a;
    //making sure that i can use V1 , V2
    if (v1 < 0 || v2 == 0) {
        cout << "Impossivel calcular" << endl;
    } //end of the if condition .....
    else {
        //at this condition i will call a function that calculate the square root(s)
        Formula(v1, v2, b);
    } //end of the else condition
    return 0;
} //end of the main method.....
//////////////////////////
//////////////////////////
//////////////////////////
//making the methods
void Formula(float v1, float v2, float b) {
    //first square root...
    float result = -b + sqrt(v1);
    result /= v2;
    cout << "R1 = " << fixed << setprecision(5) << result << endl;
    //second square root ...
    result = -b - sqrt(v1);
    result /= v2;
    cout << "R1 = " << fixed << setprecision(5) << result << endl;
} //end of the method .....

好吧,这是最简单的例子...现在这可能是我的错误,因为我是 C/C++ 的新手如果有什么问题,请告诉我,在大多数情况下,我应该尝试的最佳输入是什么?

void Formula(float v1, float v2, float b) {
    //first square root...
    float result = -b + sqrt(v1);
    result /= v2;
    cout << "R1 = " << fixed << setprecision(5) << result << endl;
    //second square root ...
    result = -b - sqrt(v1);
    result /= v2;
    cout << "R1 = " << fixed << setprecision(5) << result << endl;
} //end of the method .....

将第 2 R1 =修改为 R2 =