0
함수를 사용하여 2 차 방정식의 출력을 계산하는 프로그램을 만들려고하지만 Dev C++에서 출력을 계속 제공합니다 "반환 된 [Error] Id 1 종료 상태 "입니다. 저는 C++의 초보자입니다. 어리석은 실수를 저 지르면 미리 미안합니다.함수에서 "[Error] ld가 1 종료 상태를 반환했습니다"
#include <iostream>
#include <cmath>
using namespace std;
float equation1 (float, float, float);
float equation2 (float, float, float);
main()
{
float a, b, c, Res1, Res2;
cout << "Insert the parameters of the equation.\n";
cin >> a >> b >> c;
if (a == 0)
{
Res1 = b/c;
cout << "It's a 1st degree eq. and the result is " << Res1 << endl;
}
else
{
Res1 = equation1 (a, b, c);
Res2 = equation2 (a, b, c);
cout << "The results of the eq. are " << Res1 << " and " << Res2 << endl;
}
system ("pause");
return 0;
}
float equation1 (double a, double b, double c)
{
float D, Res1;
D = (b * b) - 4 * a * c;
Res1 = (- b + sqrt(D))/(2 * a);
return Res1;
}
float equation2 (double a, double b, double c)
{
float D, Res2;
D = (b * b) - 4 * a * c;
Res2 = (- b - sqrt(D))/(2 * a);
return Res2;
}
스택 오버플로에 오신 것을 환영합니다. [The Tour] (http://stackoverflow.com/tour)를 읽으신 후 [Help Center] (http://stackoverflow.com/help/asking)의 자료를 참조하십시오. 여기에 물어보십시오. –
아마도 당신은'int main() {...}'을 쓰려고 의도했다고 생각합니다. 두 번째로, 링커는'equation1 (float, float, float)'의 정의를 찾지 못했습니다. 마찬가지로'equation2 (float, float, float)'도 마찬가지입니다. 정의 된 함수'float equation1 (double, double, double)'은 첫 번째 선언을 오버로드합니다. – WhiZTiM
@WhiZTiM 과부하를 피하려면 어떻게해야합니까? – Sam