2008-09-02 21:15:30若殘
算出平均if.
#include
#include
int main()
{
int c,m,e,g,x,z,y;
int b;
float a;
again: printf("n★算出平均★");
printf("n請輸入國文成績:");
scanf("%d",&c);
printf("n請輸入英文成績:");
scanf("%d",&e);
printf("n請輸入數學成績:");
scanf("%d",&m);
printf("n請輸入自然成績:");
scanf("%d",&g);
printf("n請輸入公民成績:");
scanf("%d",&x);
printf("n請輸入地理成績:");
scanf("%d",&y);
printf("n請輸入歷史成績:");
scanf("%d",&z);
b = (x+y+z)/3; //算出社會平均分數公式。
a = (c+e+m+g+b)/5; //算出平均分數公式。
if (a <= 60){
printf("妳的平均分數為%0.2f,不及格",a);
}
else{
printf("你的平均分數為%d,及格了!再接再厲",a);
}
goto again;
system("pause");
return 0;
}
問題:為什麼會自動四捨五入
請阿米解答=0=
#include
int main()
{
int c,m,e,g,x,z,y;
int b;
float a;
again: printf("n★算出平均★");
printf("n請輸入國文成績:");
scanf("%d",&c);
printf("n請輸入英文成績:");
scanf("%d",&e);
printf("n請輸入數學成績:");
scanf("%d",&m);
printf("n請輸入自然成績:");
scanf("%d",&g);
printf("n請輸入公民成績:");
scanf("%d",&x);
printf("n請輸入地理成績:");
scanf("%d",&y);
printf("n請輸入歷史成績:");
scanf("%d",&z);
b = (x+y+z)/3; //算出社會平均分數公式。
a = (c+e+m+g+b)/5; //算出平均分數公式。
if (a <= 60){
printf("妳的平均分數為%0.2f,不及格",a);
}
else{
printf("你的平均分數為%d,及格了!再接再厲",a);
}
goto again;
system("pause");
return 0;
}
問題:為什麼會自動四捨五入
請阿米解答=0=
下一篇:BMI值