嘿,我正在開發一個程序,它執行許多簡單的事情來向我的老師表明我已經學會了使用函數。我已經多次閱讀這個論壇,並檢查了許多其他的,但他們都沒有解決我的問題。 如下面的代碼是連接(我認爲),我得到的錯誤列表這些消息:錯誤LNK 1120和LNK 2001
錯誤LNK1120:1周無法解析的外部
錯誤LNK2001:解析外部符號_mainCRTStartup
可有人請幫我解決這個問題!
這裏是我的代碼
#include <iostream.h>
#include <math.h>
using namespace std;
int a;
int b;
float c;
int d;
float p_theorem (int side_a, int side_b){
return sqrtf((side_a * side_a)+(side_b * side_b));
}
float p_theorem_reverse (int side_c, int side_d){
return sqrtf((side_c * side_c)-(side_d * side_d));
}
void game(int x){
if (x < 5){
cout<<"Your number is too low"<<endl<<"Please guess again: ";
cin>>x;
}
else if (x > 5){
cout<<"Your number is too big"<<endl<<"Please guess again: ";
cin>>x
}
else (x == 5){
cout<<"Good job, You guessed the number!"<<endl;
system("PAUSE");
}
}
void stuff(){
cout<<"Developed by Ely Eastman"<<endl<<"Computer 35, T.H. Rogers Secondary School, Houston, TX"<<endl;
system("PAUSE");
}
int main(void)
{
cout<<"Welcome to the Multi-Function Program"<<endl
<<"Enter 1 for finding the hypotenuse of a right triangle"<<endl
<<"Enter 2 for finding the leg of a right triangle"<<endl
<<"Enter 3 for the Guessing Game Beta"<<endl
<<"Enter 4 for Developer Information"<<endl;
cin>>d
if (d == 1){
cout<<"Welcome to the Pythagorean Theorem Solver"<<endl
<<"Please enter the length of one leg of the triangle: ";
cin>>a;
cout<<"Please enter the length of the other leg of the triangle: ";
cin>>b;
c = p_theorem(a, b);
cout<<"The length of the hypotenuse is "<<c<<endl;
system("PAUSE");
}
else if (d == 2){
cout<<"Welcome to the Reverse Pythagorean Theorem"<<endl
<<"Please enter the length of the Hypotenuse: ";
cin>>a;
cout<<"Please enter the length of the known leg: ";
cin>>b;
c = p_theorem_reverse(a, b);
cout<<"The length of the leg is: "<<g<<endl;
system("PAUSE")
}
else if (d == 3){
cout<<"Welcome to the Guessing Game Beta"<<endl
<<"Please guess a number 1-10: ";
cin<<a
game(a);
}
else if (d == 4){
stuff();
}
return 0;
}
這個程序如何進入連接階段? 'else(x == 5){}'。 「超鏈接」標籤與你的程序有什麼關係? – Mahesh 2011-05-12 19:59:48
你有幾十個失蹤的「;」以及缺少陳述。此外,遊戲「g」的長度未定義。在某些情況下,你的cin「>>」操作符被顛倒過來...... – Pepe 2011-05-12 20:01:03
爲了避免歇斯底里,我懷疑你創建了一個Windows GUI項目,當你真的想創建一個Windows控制檯項目時。 – 2011-05-12 20:05:50