English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

#include
void main()
main()
{
int i, n, k, o, p, m, h, f;
int temp;
int sum = 0; n=1;
char grade;


for(i=1; i<=n; i )
{
printf("國文學分");
scanf("%d", &h);
printf("數學學分");
scanf("%d", &f);
printf("英文學分");
scanf("%d", &m);
printf("[國文分數]:");
scanf("%d", &k);
printf("[數學分數]:");
scanf("%d", &o);
printf("[英文分數]:");
scanf("%d", &p);
sum =k*h o*f p*m;
temp=sum;

if(sum>=91)
grade= '優';
else if(sum>=81)
grade= '甲';
else if(sum>=71)
grade= '乙';
else if(sum>=61)
grade= '丙';
else
{
geade='丁';
printf("grade:%c\n", grade);
}
if(sum>=61)
{
if(temp>=1&&temp,=3)
printf("grade:%c下\n", grade);
else if(temp>=4&&<=7)
printf("grade:%c\n", grade);
else
printf("grade:%c下\n", grade);

}
{
printf("總和=%d\n", sum);
printf("平均值= %f\n", (float) sum/3);
printf("資訊二32號楊承翰\n");
system("pause");
}

2005-12-17 15:42:36 · 2 個解答 · 發問者 承翰 1 in 電腦與網際網路 程式設計

抱歉

2005-12-19 17:07:43 · update #1

2 個解答

你要的東西一點都不明確,所以只幫你改成可以動作,至於你錯在哪請自己看
程式碼對照。
=====================================================================
#include
#include
void main()
{

int i, n, k, o, p, m, h, f;
int temp;
int sum = 0; n=1;
char grade ;


for(i=1; i<=n; )
{
printf("國文學分");
scanf("%d", &h);
printf("數學學分");
scanf("%d", &f);
printf("英文學分");
scanf("%d", &m);
printf("[國文分數]:");
scanf("%d", &k);
printf("[數學分數]:");
scanf("%d", &o);
printf("[英文分數]:");
scanf("%d", &p);
sum =(k*h)+ (o*f)+(p*m);
temp=sum;

if(sum>=91)
grade= 's';
else if(sum>=81)
grade= 'a';
else if(sum>=71)
grade= 'b';
else if(sum>=61)
grade= 'c';
else
{
grade='d';
printf("grade:%c\n", grade);
}
if(sum>=61)
{
if(temp >=1 && temp <= 3)
printf("grade:%c\n", grade);
else if(temp >= 4 && temp <= 7)
printf("grade:%c\n", grade);
else
printf("grade:%c下\n", grade);
}

printf("總和=%d\n", sum);
printf("平均值= %f\n", (float) sum/3);
printf("資訊二32號楊承翰\n");
system("pause");
}
}

2005-12-18 06:03:21 · answer #1 · answered by 慶儒 1 · 0 0

/*我重新寫*/
/*
#include
int system(const char *);
MS-DOS指令可執行傳回值為 非零值
否則傳回值為零
*/
#include
void main(int argc,char *argv[]){
char *traChinese[13]={"國文","數學","英文","學分","_分數","優","甲","乙","丙","丁","上","下"," "};
int grade[6],sum=0,i,j;
float average=0;
for(j=0;j<2;j++){
for(i=0;i<3;i++){
printf("%s%s:",traChinese[i],traChinese[j+3]);
if(j==0){
scanf("%d",&grade[i]);
}else{
scanf("%d",&grade[i+3]);
}
}
}
for(i=0;i<3;i++){
sum+=grade[i]*grade[i+3];
}
average=(float)sum/3;
j=12;
if(average>90){
i=5;
if(average-5>90){
j=10;
}else if(average-5<90){
j=11;
}
}else if(average>80){
i=6;
if(average-5>80){
j=10;
}else if(average-5<80){
j=11;
}
}else if(average>70){
i=7;
if(average-5>70){
j=10;
}else if(average-5<70){
j=11;
}
}else if(average>60){
i=8;
if(average-5>60){
j=10;
}else if(average-5<60){
j=11;
}
}else{
i=9;
}
printf("分數等級\"%s%s\"\n",traChinese[i],traChinese[j]);
printf("總和 %d\n",sum);
printf("平均值 %f\n",average);
}

2005-12-18 14:33:40 · answer #2 · answered by Big_John-tw 7 · 0 0

fedest.com, questions and answers