user-0 提问: 这段程序哪些地方有问题呢

回复:
user: user-1
content: 不能把函数定义在另一个函数中！

user: user-2
content: 这样改 #include <stdio.h> #include <string.h> #define  MAX_LEN 10      /* 字符串最大长度 */ #define  STU_NUM 30      /* 最多的学生人数 */ #define  COURSE_NUM      /* 最多的考试科目数 */ int m,n; struct list { 	int num; 	char name[20]; 	int score[6]; 	double av; 	double sum; }stu[30];  int Menu(); void ReadScore(int n,int m); void AverSumofEveryCourse(void); void AverSumofEveryStudent(void); void Ascending(void); void Descending(void); void AsSortbyNum(void); void SortbyName(void); void SearchbyNum(void); void SearchbyName(void); void PrintScore(void); /*void StatisticAnalysis(void);*/  void main(void) { 	int i; 	printf("input student number(n<30)\n"); 	scanf("%d",&n); 	printf("input course number(m<=6)\n"); 	scanf("%d",&m); 	 	i=Menu(); 	while(i!=0) 	{ 		switch (i) 		{ 		case 1:ReadScore(n,m);break; 		case 2:AverSumofEveryCourse();break; 		case 3:AverSumofEveryStudent();break; 		case 4:Descending();break; 		case 5:Ascending();break; 		case 6:AsSortbyNum();break; 		case 7:SortbyName();break; 		case 8:SearchbyNum();break; 		case 9:SearchbyName();break; 			/*case 10:StatisticAnalysis();break;*/ 		case 11:PrintScore();break; 		} 		i=Menu(); 	} 	printf("\nEnd of program!\n"); }   int Menu() {   	int ch; 	printf(" \nManagement for Students' scores\n"); 	printf(" 1.Input record\n"); 	printf(" 2.Caculate total and average score of every course\n"); 	printf(" 3.Caculate total and average score of every student\n"); 	printf(" 4.Sort in descending order by score\n"); 	printf(" 5.Sort in ascending order by score\n"); 	printf(" 6.Sort in ascending order by number\n"); 	printf(" 7.Sort in dictionary order by name\n"); 	printf(" 8.Search by number\n"); 	printf(" 9.Search by name\n"); 	printf(" 10.Statistic analysis\n"); 	printf(" 11.List record\n"); 	printf(" 0.Exit\n"); 	printf(" Please Input your choice:\n"); 	for( ; ; ) 	{ 		scanf("%d",&ch); 		if(ch<0||ch>11) 			printf(" 输入错误，请选择 0-11："); 		else 			break; 	} 	return (ch); }  void ReadScore(int n,int m) {int i,j;  printf("Input student's ID, name and score:\n"); for(i=0;i<n;i++) { 	scanf("%ld\t%s",&stu[i].num,&stu[i].name); 	for(j=0;j<m;j++) 		scanf("%.0f\t",&stu[i].score[j]); } }  void AverSumofEveryCourse(void) { 	int i,j; 	for(i=0;i<m;i++) 	{ 		stu[i].sum=0; 		for(j=0;j<n;j++) 			(stu[i].sum)+=stu[j].score[i]; 		stu[i].av=(stu[i].sum)/n; 		printf("course%d:sum=%.0f,aver=%.0f\n",i+1,stu[i].sum,stu[i].av); 	} }  void Ascending(void) { 	int i,j; 	struct list temp; 	for(i=0;i<n-1;i++) 	{for(j=i+1;j<n;j++) 	if(stu[i].av>stu[j].av) 	{ temp=stu[i]; 	stu[i]=stu[j]; 	stu[j]=temp; 	} 	printf("Sort in ascending order by score:\n"); 	printf("number\tname\tscore1\tscore2\tscore3\tnum\taver\t"); 	for(i=0;i<n;i++) 	{ 		printf("%ld\t%s\t",stu[i].num,stu[i].name); 		for(j=0;j<m;j++) 			printf("%.0f\t",stu[i].score[j]); 		printf("%.0f\t%.0f\t",stu[i].sum,stu[i].av); 	} 	} }  void Descending(void) { 	int i,j; 	struct list temp; 	for(i=0;i<n-1;i++) 	{for(j=i+1;j<n;j++) 	if(stu[i].av<stu[j].av) 	{ temp=stu[i]; 	stu[i]=stu[j]; 	stu[j]=temp; 	} 	printf("Sort in descending order by score:\n"); 	printf("number\tname\tscore1\tscore2\tscore3\tnum\taver\t"); 	for(i=0;i<n;i++) 	{ 		printf("%ld\t%s\t",stu[i].num,stu[i].name); 		for(j=0;j<m;j++) 			printf("%.0f\t",stu[i].score[j]); 		printf("%.0f\t%.0f\t",stu[i].sum,stu[i].av); 	} 	} }  void AsSortbyNum(void) { 	int i,j; 	struct list temp; 	for(i=0;i<n-1;i++) 	{for(j=i+1;j<n;j++) 	if(stu[i].num>stu[j].num) 	{   temp=stu[i]; 	stu[i]=stu[j]; 	stu[j]=temp; 	} 	printf("Sort in ascending order by number:\n"); 	printf("number\tname\tscore1\tscore2\tscore3\tnum\taver\t"); 	for(i=0;i<n;i++) 	{ 		printf("%ld\t%s\t",stu[i].num,stu[i].name); 		for(j=0;j<m;j++) 			printf("%.0f\t",stu[i].score[j]); 		printf("%.0f\t%.0f\t",stu[i].sum,stu[i].av); 	} 	} }  void SortbyName(void) { 	int i,j; 	struct list temp; 	for(i=0;i<n-1;i++) 	{for(j=i+1;j<n;j++) 	if(strcmp((stu[i].name),(stu[j].name))>0) 	{   temp=stu[i]; 	stu[i]=stu[j]; 	stu[j]=temp; 	} 	printf("Sort in dictionary order by name:\n"); 	printf("number\tname\tscore1\tscore2\tscore3\tnum\taver\t"); 	for(i=0;i<n;i++) 	{ 		printf("%ld\t%s\t",stu[i].num,stu[i].name); 		for(j=0;j<m;j++) 			printf("%.0f\t",stu[i].score[j]); 		printf("%.0f\t%.0f\t",stu[i].sum,stu[i].av); 	} 	} }  void SearchbyNum(void) { 	int j; 	int number,i,k=0; 	printf("Input the number you want to search:"); 	scanf("%d",&number); 	for(i=0;i<n;i++) 	{if((stu[i].num)==number) 	{printf("%ld\t%s\t",stu[i].num,stu[i].name); 	for(j=0;j<m;j++) 		printf("%.0f\t",stu[i].score[j]); 	printf("%.0f\t%.0f\t",stu[i].sum,stu[i].av); 	k=1;} 	} 	if(k=0) printf("Not found!"); }  void SearchbyName(void) { 	int i,j; 	char nam[20]; 	int k=0; 	printf("Input the number you want to search:"); 	gets(nam); 	for(i=0;i<n;i++) 	{if(strcmp((stu[i].name),nam)==0) 	{printf("%ld\t%s\t",stu[i].num,stu[i].name); 	for(j=0;j<m;j++) 		printf("%.0f\t",stu[i].score[j]); 	printf("%.0f\t%.0f\t",stu[i].sum,stu[i].av); 	k=1;} 	} 	if(k=0) printf("Not found!"); }  void PrintScore(void) { 	int i,j; 	printf("number\tname\tscore1\tscore2\tscore3\tnum\taver\n"); 	for(i=0;i<n;i++) 	{ 		printf("%ld\t%s\t",stu[i].num,stu[i].name); 		for(j=0;j<m;j++) 			printf("%.0f\t",stu[i].score[j]); 		printf("%.0f\t%.0f\t",stu[i].sum,stu[i].av); 	} }   void AverSumofEveryStudent(void) { 	int i,j; 	for(i=0;i<n;i++) 	{ 		stu[i].sum=0; 		for(j=0;j<m;j++) 			stu[i].sum+=stu[i].score[j]; 		stu[i].av=(stu[i].sum)/m; 		printf("stu%d:sum=%.0f,aver=%.0f\n",i+1,stu[i].sum,stu[i].av); 	} }  /*void StatisticAnalysis(void) { int i; for(i=0;i<m;i++) { printf("for course%d:\n",i+1); printf("<60\t%d\t%.2f%\n",,); printf("60-69\t%d\t%.2f%\n",,) printf("70-79\t%d\t%.2f%\n",,) printf("80-89\t%d\t%.2f%\n",,) printf("90-99\t%d\t%.2f%\n",,) printf("100\t%d\t%.2f%\n",,) } }*/