請問各位大大 5ㄍ數字用C語言 比大小
我哪裡錯ㄌ 為什麼編譯都不過
可以告訴我哪裡錯ㄌㄇ?
#include
#include
int main ()
{
int num1,num2,num3,num4,num5;
printf("plz enter first number\n"); scanf("%d",&num1);
printf("plz enter second number\n"); scanf("%d",&num2);
printf("plz enter third number\n"); scanf("%d",&num3);
printf("plz enter foreth number\n"); scanf("%d",&num4);
printf("plz enter fiveth number\n"); scanf("%d",&num5);
if(num1>num2){
if(num1>num3){
if(num1>num4){
if(num1>num5){
printf("%d is max \n", num1); }
}
}
}
if(num2>num1){
if(num2>num3){
if(num2>num4){
if(num2>num5){
printf("%d is max \n", num2); }
}
}
}
if(num3>num2){
if(num3>num1){
if(num3>num4){
if(num3>num5){
printf("%d is max \n", num3); }
}
}
}
if(num4>num2){
if(num4>num3){
if(num4>num1){
if(num4>num5){
printf("%d is max \n", num4); }
}
}
}
if(num5>num2){
if(num5>num3){
if(num5>num4){
if(num5>num1){
printf("%d is max \n", num5); }
}
}
}
system("PAUSE");
return 0;
}
2007-10-21 15:40:41 · 2 個解答 · 發問者 少 1 in 電腦與網際網路 ➔ 程式設計
幫你改好了,主要問題出在system那個部分
後面多了很多個全形空白
#include
#include
int main ()
{
int num1,num2,num3,num4,num5;
printf("plz enter first number\n"); scanf("%d",&num1);
printf("plz enter second number\n"); scanf("%d",&num2);
printf("plz enter third number\n"); scanf("%d",&num3);
printf("plz enter foreth number\n"); scanf("%d",&num4);
printf("plz enter fiveth number\n"); scanf("%d",&num5);
if(num1>num2){
if(num1>num3){
if(num1>num4){
if(num1>num5){
printf("%d is max \n", num1); }
}
}
}
if(num2>num1){
if(num2>num3){
if(num2>num4){
if(num2>num5){
printf("%d is max \n", num2); }
}
}
}
if(num3>num2){
if(num3>num1){
if(num3>num4){
if(num3>num5){
printf("%d is max \n", num3); }
}
}
}
if(num4>num2){
if(num4>num3){
if(num4>num1){
if(num4>num5){
printf("%d is max \n", num4); }
}
}
}
if(num5>num2){
if(num5>num3){
if(num5>num4){
if(num5>num1){
printf("%d is max \n", num5); }
}
}
}
system("PAUSE");
return 0;
}
2007-10-21 16:04:28 · answer #1 · answered by Joybo 5 · 1⤊ 0⤋
#include
#include
int main(int argc, char* argv[]){
//=====START=====//
int a=1,b=2,c=3,d=4,e=5,max;
max=(a>b?(a>c?(a>d?(a>e?a:e):(d>e?d:e)):(c>d?(c>e?c:e):(d>e?d:e))):(b>c?(b>d?(b>e?b:e):(d>e?d:e)):(c>d?(c>e?c:e):(d>e?d:e))));
printf("%d\n",max);
//=====END=====//
system("PAUSE");
return 0;
}
2007-10-21 16:16:56 · answer #2 · answered by Big_John-tw 7 · 0⤊ 0⤋