学生成績管理システム——C言語


実行環境:Visual Studio 2010
/*        */

#include
#include//       
#include
#include

struct stu{
	char n[50];
	double g;
}num[5];

int main(void){
	
	printf("     |--------------------------------------|
"
); printf(" | |
"
); printf(" |--------------------------------------|
"
); printf(" | 1-- |
"
); printf(" | 2-- |
"
); printf(" | 3-- |
"
); printf(" | 4-- |
"
); printf(" | 5-- |
"
); printf(" | 6-- |
"
); printf(" |--------------------------------------|
"
); printf(" ENTER "); getchar(); system("cls"); printf("---------------------------------------------
"
); printf("
"
); int k; for(k = 0;k < 5;k++) scanf("%s %lf",num[k].n,&num[k].g); double max,min; int m,t;// for(k = 0;k < 5;k++){ if(k == 0){ max = min = num[k].g; m = t = 0; } else{ if(max <= num[k].g){ max = num[k].g; m = k; } if(min >= num[k].g){ min = num[k].g; t = k; } } } int average; average = num[0].g + num[1].g + num[2].g + num[3].g +num[4].g; getchar(); system("cls"); printf("---------------------------------------------
"
); printf(" %s:%.1f
"
,num[m].n,num[m].g); printf(" %s:%.1f
"
,num[t].n,num[t].g); getchar(); printf(" : %.1f
"
,average/5.0); printf("
"
); getchar(); printf(" :
"
); for(k = 0;k < 5;k++) if(num[k].g < average/5.0) printf("%s:%.1f
"
,num[k].n,num[k].g); printf("
"
); printf(" :
"
); for(k = 0;k < 5;k++) if(num[k].g > average/5.0) printf("%s:%.1f
"
,num[k].n,num[k].g); printf("---------------------------------------------
"
); printf(" ENTER "); getchar(); system("cls"); printf("---------------------------------------------
"
); char sb[20]; printf(" :"); scanf("%s",sb); printf("%s :",sb); getchar(); for(k = 0;k < 5;k++) if(strcmp(sb,num[k].n) == 0) printf("%.1f
"
,num[k].g); printf("---------------------------------------------
"
); printf(" ENTER "); getchar(); system("cls"); printf("---------------------------------------------
"
); printf("



"
); printf("
"
); printf("|
"
); printf("|
"
); printf("|\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf
"
,num[0].g,num[1].g,num[2].g,num[3].g,num[4].g); int c; for(k = 11;k >= 0;k--){ printf("|"); if(k == 0) printf("-------------------------------------------------->
"
); else{ for(c = 0;c < 5;c++){ if(num[c].g/10.0 < k-1) printf(" "); else if(( (int)num[c].g )/10 == k-1) printf(" __"); else printf(" | |"); if(c == 4) printf("
"
); } }} printf("\t%s\t%s\t%s\t%s\t%s\t
"
,num[0].n,num[1].n,num[2].n,num[3].n,num[4].n); return 0; }