|
■■■十万火急~~~求救!哪位大侠能帮忙标示下注释~
■■■十万火急~~~求救!哪位大侠能帮忙标示下注释~
程序注释,算法解释,还有流程图都写出来
#include"stdio.h"
#define NULL 0
#define N1 3
#define N2 3
#define STR struct student
#include "string.h"
int sco[N2+2];
STR
{long num;
char name[10];
int score[N2];
int average;
int total;
};
STR stu[N1];
void input()
{int i,j;
printf("=======there are %d students and %d subjects.========\n",N1,N2);
printf("=======Now input the student`s num,name,score:====\n");
for(i=0;i<N1;i++)
{scanf("%6ld %s" ,&stu[i].num,stu[i].name);
for(j=0;j<N2;j++)
scanf("%6d",&stu[i].score[j]);
}
}
void averandsum ()
{
int i,j,b=0,c=0;
for(i=0;i<N1;i++)
{ stu[i].total=0;
for(j=0;j<N2;j++)
stu[i].total+=stu[i].score[j];
stu[i].average=stu[i].total/N2;
printf("Input the %d student`average and total:\n",i+1) ;
printf("the average is %6d\nthe total is %6d",stu[i].average,stu[i].total);
printf("\n");
}
for(i=0;i<N2;i++)
{b=0;
for(j=0;j<N1;j++)
b=b+stu[j].score[i];
sco[i]=b/N1; }
for(i=0;i<N2;i++)
printf(" subject %d average is %6d.\n",i+1, sco[i]);
for (i=0;i<N1;i++)
c=c+stu[i].average;
c=c/N1;
sco[N2]=c;
printf("=======the all average is %6d.========\n",c);
b=0;
for(i=0;i<N1;i++)
b=b+stu[i].total;
sco[N2+1]=b/N1;
}
void order()
{
int i,j,p,a[N2],b,c,d;
char str[10] ;
printf("=========orderthe student ==========\n");
for(i=0;i<N1-1;i++)
{p=i;
for(j=i+1;j<N1;j++)
if(stu[j].total>=stu[p].total) p=j;
printf("The num %ldstudent's order is %d",stu[p].num,i+1);
b=stu[i].num;stu[i].num=stu[p].num;stu[i].num=b;
strcpy(str,stu[i].name);
strcpy(stu[i].name,stu[p].name);
strcpy(stu[p].name,str);
for(j=0;j<N2;j++)
{a[j]=stu[i].score[j];
stu[i].score[j]=stu[p].score[j];
stu[p].score[j]=a[j];
}
c=stu[i].average ;
stu[i].average=stu[p].average;
stu[p].average=c;
d=stu[i].total;
stu[i].total=stu[p].total;
stu[i].total=d;
}
}
void search ()
{int i,j;
char a;
printf("Input the first letter.\n");
a=getchar();
printf("the student`s the first word is %c .",a);
printf("\n=======search the student score======\n");
for(i=0;i<N1;i++)
{ if(a==stu[i].name[0])
printf("the cha chu de xue sheng de scores is :\n");
printf("%6ld,%s", stu[i].num,stu[i].name);
for (j=0;j<N2;j++)
printf("%6d", stu[i].score[j]);
printf("%6d %6d",stu[i].average,stu[i].total);
}
}
void revise()
{int i,j;
char str[N2];
long a;
int b[N2];
printf("======Input the student`s revised score:======\n ");
for(j=0;j<N2;j++)
scanf("%d",&b[j]);
printf("========input the student`s num:========\n ");
scanf("%ld",&a);
printf("====shu ru the student`s name:========\n");
scanf("%s",str);
for(i=0;i<N1;i++)
{ if(a==stu[i].num)
for(j=0;j<N2;j++)
stu[i].score[j]=b[j];
strcpy(stu[i].name,str);
}
}
output()
{ int j, i;
printf("output the student :\n");
printf("*********xue sheng cheng ji guan li *********\n");
printf("NUM---NAME");
for(j=0;j<N2;j++)
printf("--SCORE%d",j+1);
printf("-AVERAGE-TOTAL");
printf("\n");
for(i=0;i<N1;i++)
{printf("|%6ld|%s",stu[i].num,stu[i].name);
for (j=0;j<N2;j++)
printf("|%6d", stu[i].score[j]);
printf("|%6d |%6d|",stu[i].average,stu[i].total);
printf("\n");
}
printf("The all average:");
for(j=0;j<N2+2;j++)
printf("|%6d",sco[j]);
}
void menu_f()
{
system("pause");
system("cls");
printf("\n1.Input student number,name,score.");
printf("\n2.Work out the student average and total.");
printf("\n3.Order the student.");
printf("\n4.Search the student.");
printf("\n5.Revise the student`s score.");
printf("\n6.Output the student`s score.");
printf("\n0.Exit.");
printf("\n Choice:");
}
main()
{int nMenuChoice;
while(1)
{menu_f();
printf("Please make the choise:\n ");
scanf("%d",&nMenuChoice);
if(nMenuChoice==0) break;
else if(nMenuChoice<0||nMenuChoice>6) continue;
switch(nMenuChoice)
{
case 1: printf("Input the student`name,num,and score:\n") ;
input( );
break;
case 2: printf("Work out the student average and total:\n");
averandsum ( );
break;
case 3: printf("Order the student\n");
order( );
break;
case 4: printf("Search the student.\n");
search() ;
break;
case 5: printf("Revise the student`s score\n.");
revise( );
break;
case 6: printf("shu chu the student`s score.\n");
output( ) ;
break;
}
}
}
这段程序帮忙标上注释,可以的话最好画张流程图,感激不尽~
imac902@hotmail.com
qq:184541128
时间很紧,要在下午6:00前搞定,谢谢各位...
----------------------------------------------
|
欢迎继续阅读楼主其他信息
|