⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 к+

📁 学生成绩管理源代码
💻
字号:
// stdafx.cpp : source file that includes just the standard includes
//	学生成绩管理系统.pch will be the pre-compiled header
//	stdafx.obj will contain the pre-compiled type information

#include <stdio.h>
#include <conio.h>
#define N1 2
#define N2 3
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("\t\tthe average score table of all students\n");
printf("\t\tNo.\t\tave_score\n");
for(i=0;i<N1;i++)
printf("\t\tNo.%d\t\t%6.2f\n",i,S_Ave[i]);
printf("Press any key to return to main menu....\n");
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("\t\tthe average score table of all courses\n");
printf("\t\tCourse Name\t\tave_score\n");
for(i=0;i<N2;i++)
printf("\t\t%s\t\t%6.2f\n",name[i],C_Ave[i]);
printf("Press any key to return the main menu......\n");
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\t%d\t%6.2f\n",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");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -