| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 511 人关注过本帖
标题:菜鸟自己解决不了了,再次求高手帮忙。
取消只看楼主 加入收藏
canniao
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2004-12-14
收藏
 问题点数:0 回复次数:0 
菜鸟自己解决不了了,再次求高手帮忙。
再次求人,有错误 能帮我一下么?

如果想输出所有有不及格课程的学生的学号、全部课程的成绩、平均成绩;如何修改,可以将修改正确的源代码我看一下么。辛苦了

#include <stdio.h> #include <conio.h> #define N1 9 #define N2 10 float Stu_Score[N1][N2]; float S_Ave[N1]; float C_Ave[N2]; int A[N2];

/*--------------------function declaration-----------------*/ void print_menu(); void input_score(); /*input students‘ scores*/ void print_s_ave(); /*print students‘ average score */ void stu_ave(); /* count students‘ average score */ void course_ave(); /* count courses‘ average score */ void print_c_ave(); /* print courses‘ average score */ void find_max_course(); /* search the max score */ void fangcha(); /*count the fangcha */

/*------------------------main()---------------------------*/ int main() { char ch;

for(;;){ do{ print_menu(); ch=toupper(getch()); }while (ch!=‘I‘ && ch!=‘S‘ && ch!=‘C‘ && ch!=‘Q‘); switch(ch){ case ‘I‘:input_score(); break; case ‘S‘:stu_ave(); print_s_ave(); break; case ‘C‘:course_ave(); print_c_ave(); break; case ‘Q‘:clrscr(); exit(0); }/* end of switch */ } /* end of for statement */

}

/*------------------------input_score()---------------------*/ void input_score(void) { int i,j; clrscr();

for(i=0;i<N1;i++){ printf("No.%d",i+1); for(j=0;j<N2;j++) scanf("%f",&Stu_Score[i][j]);

} }

/*-------------------------stu_ave()--------------------------*/ void stu_ave(void) {

int i,j;

for (i=0;i<N1;i++ ) S_Ave[i]=0;

for(i=0;i<N1;i++){ for(j=0;j<N2;j++) S_Ave[i]+=Stu_Score[i][j]; S_Ave[i]/=N2; }

}

void print_s_ave(void) { int i;

clrscr();

printf(" the average score table of all students "); printf(" No. ave_score "); for(i=0;i<N1;i++) printf(" No.%d %6.2f ",i,S_Ave[i]); printf("Press any key to return to main menu.... "); getch(); }

/*--------------------------course_ave()-----------------------*/ void course_ave(void) { int i,j;

for (i=0;i<N2;i++ ) C_Ave[i]=0;

for(i=0;i<N2;i++){ for(j=0;j<N1;j++) C_Ave[i]+=Stu_Score[j][i]; C_Ave[i]/=N1; }

}

void print_c_ave(void) { int i; char *name[]={"math","chinese","english","physics","chemistry"};

clrscr();

printf(" the average score table of all courses "); printf(" Course Name ave_score "); for(i=0;i<N2;i++) printf(" %s %6.2f ",name[i],C_Ave[i]); printf("Press any key to return the main menu...... "); getch(); }

/*--------------------------find_max_course()-----------------------*/ void find_max_course(void) { int i,j,t; char *name[]={"math","chinese","english","physics","chemistry"};

clrscr(); for(i=0;i<N2;i++){ t=0; for(j=1;j<N1;j++) if(Stu_Score[t][i]<Stu_Score[j][i]) t=j; printf("%s %d %6.2f ",name[i],t+1,Stu_Score[t][i]);

}

}

/*---------------------------fangcha()---------------------------*/ void fangcha(void) { float s1=0,s2=0,f; int i;

stu_ave(); for(i=0;i<N1;i++){ s1=s1+S_Ave[i]*S_Ave[i]; s2=s2+S_Ave[i]; }

s2/=N1; f=s1/N1-s2*s2;

clrscr(); printf("fangcha is %6.2f",f); }

/*-------------------print_menu()--------------------*/ void print_menu() { clrscr(); textattr(BLUE*16|YELLOW); gotoxy(15,5); cprintf("1.(I)nput Students‘ score"); textattr(BLUE*16|YELLOW); gotoxy(15,9); cprintf("2.(S)tudents‘ average score"); textattr(BLUE*16|YELLOW); gotoxy(15,13); cprintf("3.(C)ourse‘ average score"); textattr(BLUE*16|YELLOW); gotoxy(15,17); cprintf("4.(Q)uit the system"); }

2004-12-16 12:46
快速回复:菜鸟自己解决不了了,再次求高手帮忙。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015312 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved