user-0 提问: 请求c语言大神支支招，看一下为什么会报错，感谢！

回复:
user: user-1
content: 1，用了关键字命名变量。 2，无返回值函数返回int 3，这你自己写的吗  #include <stdio.h> #include <stdlib.h> #define N 30   void Readscore(int id[], int score[], int n);  int Average(int score[], int n);  void Scoresort(int id[], int score[], int n);  void Idsort(int id[], int score[], int n);  int Selectsort(int id[], int score[], int n, int x);  void Scoreclass(int score[], int n);  void Showinfo(int id[], int score[], int n);   int main() { 	int num, score[N], aver, n, sum, id[N], i, m, x, k, great = 0, better = 0, middle = 0, low = 0, lower = 0;   	while (1) { 		//首页选择项的输出  		printf("----------------\n"); 		printf("1.Input record\n"); 		printf("2.Caculate total and average score of course\n"); 		printf("3.Sort in descending order by score\n"); 		printf("4.Sort in ascending order by number\n"); 		printf("5.Search by number\n"); 		printf("6.Sta1tistic analysis\n"); 		printf("7.List record\n"); 		printf("0.Exit\n"); 		printf("Please enter your choice\n"); 		scanf("%d", &num); 		//用户输入功能键的输入输出   		switch (num) { 		case 0:  			break; 		case 1: 			printf("Input n:\n"); 			scanf("%d", &n); 			Readscore(id, score, n); 			break;  		case 2: 			sum = Average(score, n); 			printf("Sum score is %d\n", sum); 			printf("Average score is %d\n", sum / n); 			break; 		case 3: 			Scoresort(id, score, n); 			for (i = 0; i <= n - 1; i++) { 				printf("%3d%5d\n", id[i], score[i]); 			} 			break; 		case 4: 			Idsort(id, score, n); 			for (i = 0; i <= n - 1; i++) { 				printf("%3d%5d\n", id[i], score[i]); 			} 			break; 		case 5: 			printf("Input id:\n"); 			scanf("%d", &x); 			m = Selectsort(id, score, n, x); 			if (m == -1) { 				printf("查询错误\n"); 			} 			else { 				printf("----------------\n"); 				printf("id:%3d score:%3d 排名:%3d\n", id[m], score[m], m + 1); 			} 			break; 		case 6: 			Scoreclass(score, n); 			break; 		case 7: 			Showinfo(id, score, n); 			sum = Average(score, n); 			printf("----------------\n"); 			printf("Sum score is %d\n", sum); 			printf("Average score is %d\n", sum / n); 			break;   		default: 			printf("Invalid operator\n");     		} 	} } //输出分数段 void Scoreclass(int score[], int n) {  	int i, j, count, k; 	double bate, m; 	m = n; 	int begin[5] = { 0,60,70,80,90 }; 	int end[5] = { 59,69,79,89,100 }; 	char re[][10] = { "不及格","及格","中等","良好","优秀" };  	for (i = 0, j = 0; i <= n, j < 5; i++, j++) { 		count = 0; 		bate = 0; 		for (k = 0; k < n; k++) { 			if ((begin[i] <= score[k]) && (end[i] >= score[k])) { 				count += 1; 				bate = (100 * count) / m; 			}  		}  		printf("%s的学生人数为:%d ,所占百分比为%.2f\n", re[j], count, bate / 100);  	}  } //输出每个学生的学号和成绩 void Showinfo(int id[], int score[], int n) { 	int i; 	for (i = 0; i <= n - 1; i++) { 		printf("id:%3d score:%3d\n", id[i], score[i]); 	} } //根据学号查询学生成绩 int Selectsort(int id[], int score[], int n, int x) { 	int temp_score, i, j, temp_id, k; 	for (i = 0; i < n - 1; i++) { 		for (j = i + 1; j < n; j++) { 			if (score[i] < score[j]) { 				temp_score = score[i]; 				score[i] = score[j]; 				score[j] = temp_score; 				temp_id = id[i]; 				id[i] = id[j]; 				id[j] = temp_id; 			} 		} 	} 	for (k = 0; k < n; k++) { 		if (id[k] == x) 			return k;  	}return -1;     } //根据学号从小到大打印成绩 void Idsort(int id[], int score[], int n) { 	int temp_score, i, j, temp_id; 	for (i = 0; i < n - 1; i++) { 		for (j = i + 1; j < n; j++) { 			if (id[i] > id[j]) { 				temp_score = score[i]; 				score[i] = score[j]; 				score[j] = temp_score; 				temp_id = id[i]; 				id[i] = id[j]; 				id[j] = temp_id; 			} 		} 	}   } //从高到低打印成绩 void Scoresort(int id[], int score[], int n) { 	int temp_score, i, j, temp_id; 	for (i = 0; i < n - 1; i++) { 		for (j = i + 1; j < n; j++) { 			if (score[i] < score[j]) { 				temp_score = score[i]; 				score[i] = score[j]; 				score[j] = temp_score; 				temp_id = id[i]; 				id[i] = id[j]; 				id[j] = temp_id; 			} 		} 	}   } //计算班级平均分 int Average(int score[], int n) { 	int i, sum = 0; 	for (i = 0; i < n; i++) { 		sum += score[i]; 	} 	return sum; } //录入学生成绩 void Readscore(int id[], int score[], int n) {   	int i; 	for (i = 0; i < n; i++) { 		printf("Input student's id and score:"); 		scanf("%d %d", &id[i], &score[i]); 		if (score[i] < 0) { 			printf("成绩输入错误\n"); 			return; 		} 	} 	system("pause"); }

user: user-0
content: 引用 1 楼 user-1的回复:1，用了关键字命名变量。 2，无返回值函数返回int 3，这你自己写的吗  #include <stdio.h> #include <stdlib.h> #define N 30   void Readscore(int id[], int score[], int n);  int Average(int score[], int n);  void Scoresort(int id[], int score[], int n);  void Idsort(int id[], int score[], int n);  int Selectsort(int id[], int score[], int n, int x);  void Scoreclass(int score[], int n);  void Showinfo(int id[], int score[], int n);   int main() { 	int num, score[N], aver, n, sum, id[N], i, m, x, k, great = 0, better = 0, middle = 0, low = 0, lower = 0;   	while (1) { 		//首页选择项的输出  		printf("----------------\n"); 		printf("1.Input record\n"); 		printf("2.Caculate total and average score of course\n"); 		printf("3.Sort in descending order by score\n"); 		printf("4.Sort in ascending order by number\n"); 		printf("5.Search by number\n"); 		printf("6.Sta1tistic analysis\n"); 		printf("7.List record\n"); 		printf("0.Exit\n"); 		printf("Please enter your choice\n"); 		scanf("%d", &num); 		//用户输入功能键的输入输出   		switch (num) { 		case 0:  			break; 		case 1: 			printf("Input n:\n"); 			scanf("%d", &n); 			Readscore(id, score, n); 			break;  		case 2: 			sum = Average(score, n); 			printf("Sum score is %d\n", sum); 			printf("Average score is %d\n", sum / n); 			break; 		case 3: 			Scoresort(id, score, n); 			for (i = 0; i <= n - 1; i++) { 				printf("%3d%5d\n", id[i], score[i]); 			} 			break; 		case 4: 			Idsort(id, score, n); 			for (i = 0; i <= n - 1; i++) { 				printf("%3d%5d\n", id[i], score[i]); 			} 			break; 		case 5: 			printf("Input id:\n"); 			scanf("%d", &x); 			m = Selectsort(id, score, n, x); 			if (m == -1) { 				printf("查询错误\n"); 			} 			else { 				printf("----------------\n"); 				printf("id:%3d score:%3d 排名:%3d\n", id[m], score[m], m + 1); 			} 			break; 		case 6: 			Scoreclass(score, n); 			break; 		case 7: 			Showinfo(id, score, n); 			sum = Average(score, n); 			printf("----------------\n"); 			printf("Sum score is %d\n", sum); 			printf("Average score is %d\n", sum / n); 			break;   		default: 			printf("Invalid operator\n");     		} 	} } //输出分数段 void Scoreclass(int score[], int n) {  	int i, j, count, k; 	double bate, m; 	m = n; 	int begin[5] = { 0,60,70,80,90 }; 	int end[5] = { 59,69,79,89,100 }; 	char re[][10] = { "不及格","及格","中等","良好","优秀" };  	for (i = 0, j = 0; i <= n, j < 5; i++, j++) { 		count = 0; 		bate = 0; 		for (k = 0; k < n; k++) { 			if ((begin[i] <= score[k]) && (end[i] >= score[k])) { 				count += 1; 				bate = (100 * count) / m; 			}  		}  		printf("%s的学生人数为:%d ,所占百分比为%.2f\n", re[j], count, bate / 100);  	}  } //输出每个学生的学号和成绩 void Showinfo(int id[], int score[], int n) { 	int i; 	for (i = 0; i <= n - 1; i++) { 		printf("id:%3d score:%3d\n", id[i], score[i]); 	} } //根据学号查询学生成绩 int Selectsort(int id[], int score[], int n, int x) { 	int temp_score, i, j, temp_id, k; 	for (i = 0; i < n - 1; i++) { 		for (j = i + 1; j < n; j++) { 			if (score[i] < score[j]) { 				temp_score = score[i]; 				score[i] = score[j]; 				score[j] = temp_score; 				temp_id = id[i]; 				id[i] = id[j]; 				id[j] = temp_id; 			} 		} 	} 	for (k = 0; k < n; k++) { 		if (id[k] == x) 			return k;  	}return -1;     } //根据学号从小到大打印成绩 void Idsort(int id[], int score[], int n) { 	int temp_score, i, j, temp_id; 	for (i = 0; i < n - 1; i++) { 		for (j = i + 1; j < n; j++) { 			if (id[i] > id[j]) { 				temp_score = score[i]; 				score[i] = score[j]; 				score[j] = temp_score; 				temp_id = id[i]; 				id[i] = id[j]; 				id[j] = temp_id; 			} 		} 	}   } //从高到低打印成绩 void Scoresort(int id[], int score[], int n) { 	int temp_score, i, j, temp_id; 	for (i = 0; i < n - 1; i++) { 		for (j = i + 1; j < n; j++) { 			if (score[i] < score[j]) { 				temp_score = score[i]; 				score[i] = score[j]; 				score[j] = temp_score; 				temp_id = id[i]; 				id[i] = id[j]; 				id[j] = temp_id; 			} 		} 	}   } //计算班级平均分 int Average(int score[], int n) { 	int i, sum = 0; 	for (i = 0; i < n; i++) { 		sum += score[i]; 	} 	return sum; } //录入学生成绩 void Readscore(int id[], int score[], int n) {   	int i; 	for (i = 0; i < n; i++) { 		printf("Input student's id and score:"); 		scanf("%d %d", &id[i], &score[i]); 		if (score[i] < 0) { 			printf("成绩输入错误\n"); 			return; 		} 	} 	system("pause"); }  #include <stdio.h> #include <stdlib.h> #define N 30   void Readscore(int name[],int id[],int score[],int period[],int credit[],int n);  int Average(int name[],int id[],int score[],int period[],int credit[],int n);  void Scoresort(int name[],int id[],int score[],int period[],int credit[],int n);  int Selectsort(int name[],int id[],int score[],int period[],int credit[],int n,int x);  void Scoreclass(int name[],int id[],int score[],int period[],int credit[],int n);  void Showinfo(int name[],int id[],int score[],int period[],int credit[],int n);   int main() { 	int num,score[N],aver,n,sum,name[N],period[N],credit[N],id[N],i,m,x,k,great=0,better=0,middle=0,low=0,lower=0;   while(1){ 									//首页选择项的输出      printf("----------------\n");     printf("1.输入学生的课程信息\n");     printf("2.计算课程总分和平均分\n");     printf("3.按成绩降序输出成绩表\n");     printf("4.按学号查询学生信息\n");     printf("5.列出分数段分数\n");     printf("选择功能\n");     scanf("%d",&num); 									//用户输入功能键的输入输出       switch(num){         case 1:             printf("输入班级学生人数 n:\n");             scanf("%d",&n);              			Readscore(name,id,score,period,credit,n);             break;          case 2:             sum=Average(name,id,score,period,credit,n);             printf("总分是： %d\n",sum);             printf("平均分是： %d\n",sum/n);             break;         case 3:             Scoresort(name,id,score,period,credit,n);             for(i=0;i<=n-1;i++){                 printf("%5d%3d%%3d%3d5d\n",name[i],id[i],score[i],period[i],credit[i]);             }             break;                  case 5:             printf("输入学号：\n");             scanf("%d",&x);             m=Selectsort(name,id,score,period,credit,n,x);             if(m==-1){                 printf("查询错误\n");             }else{                 printf("----------------\n");                 printf("姓名：%5d 学号：%3d 分数：%3d 学时：%3d 学分：%3d 排名：%3d\n",id[m],score[m],m+1);             }             break;                case 7:             Showinfo(name,id,score,period,credit,n);             sum=Average(name,id,score,period,credit,n);             printf("----------------\n");             printf("总分是： %d\n",sum);             printf("平均分是： %d\n",sum/n);             break;           default:             printf("Invalid operator\n");       } } } //输出分数段 void Scoreclass(int name[],int id[],int score[],int period[],int credit[],int n){      int i,j,count,k;     double bate,m;     m=n;     int begin[5]={0,60,70,80,90};     int end[5]={59,69,79,89,100};     char classs[]={"不及格,及格,中等,良好,优秀"};      for(i=0,j=0;i<=n,j<5;i++,j++){             count =0;             bate=0;        for(k=0;k<n;k++){           if((begin[i]<=score[k])&&(end[i]>=score[k])){              count+=1;              bate=(100*count)/m;           }         }         printf("%s的学生人数为:%d ,所占百分比为%.2f\n",classs[1],count,bate/100);      }  } //输出每个学生的学号和成绩 void Showinfo(int name[],int id[],int score[],int period[],int credit[],int n){     int i;     for(i=0;i<=n-1;i++){         printf("姓名：%5d 学号：%3d 分数：%3d 学时：%3d 学分：%3d\n",name[i],id[i],score[i],period[i],credit[i]);     } } //根据学号查询学生成绩 int Selectsort(int name[],int id[],int score[],int period[],int credit[],int n,int x){     int temp_score,i,j,temp_id,k;     for(i=0;i<n-1;i++){         for(j=i+1;j<n;j++){             if(score[i]<score[j]){                     temp_score = score[i];                     score[i]=score[j];                     score[j]=temp_score;                     temp_id=id[i];                     id[i]=id[j];                     id[j]=temp_id;             }         }     }     for(k=0;k<n;k++){         if(id[k]==x)             return k;      }return -1;     }  //从高到低打印成绩 void Scoresort(int name[],int id[],int score[],int period[],int credit[],int n){     int temp_score,i,j,temp_id;     for(i=0;i<n-1;i++){         for(j=i+1;j<n;j++){             if(score[i]<score[j]){                     temp_score = score[i];                     score[i]=score[j];                     score[j]=temp_score;                     temp_id=id[i];                     id[i]=id[j];                     id[j]=temp_id;             }         }     }   } //计算班级平均分 int Average(int name[],int id[],int score[],int period[],int credit[],int n){     int i,sum=0;     for(i=0;i<n;i++){         sum+=score[i];     }     return sum; } //录入学生成绩 void Readscore(int name[],int id[],int score[],int period[],int credit[],int n){       int i;     for(i=0;i<n;i++){         printf("输入学生的姓名，学号，分数，学时，学分");         scanf("%d %d %d %d %d",&name[i],&id[i],&score[i],&period[i],&credit[i]);         if(score[i]<0){             printf("成绩输入错误\n");                      }     } 		system("pause"); }       这是我用了改过后的，但是编译运行后，陷入了一个死循环，能帮帮我吗

user: user-0
content: 引用 1 楼 user-1的回复:1，用了关键字命名变量。 2，无返回值函数返回int 3，这你自己写的吗  #include <stdio.h> #include <stdlib.h> #define N 30   void Readscore(int id[], int score[], int n);  int Average(int score[], int n);  void Scoresort(int id[], int score[], int n);  void Idsort(int id[], int score[], int n);  int Selectsort(int id[], int score[], int n, int x);  void Scoreclass(int score[], int n);  void Showinfo(int id[], int score[], int n);   int main() { 	int num, score[N], aver, n, sum, id[N], i, m, x, k, great = 0, better = 0, middle = 0, low = 0, lower = 0;   	while (1) { 		//首页选择项的输出  		printf("----------------\n"); 		printf("1.Input record\n"); 		printf("2.Caculate total and average score of course\n"); 		printf("3.Sort in descending order by score\n"); 		printf("4.Sort in ascending order by number\n"); 		printf("5.Search by number\n"); 		printf("6.Sta1tistic analysis\n"); 		printf("7.List record\n"); 		printf("0.Exit\n"); 		printf("Please enter your choice\n"); 		scanf("%d", &num); 		//用户输入功能键的输入输出   		switch (num) { 		case 0:  			break; 		case 1: 			printf("Input n:\n"); 			scanf("%d", &n); 			Readscore(id, score, n); 			break;  		case 2: 			sum = Average(score, n); 			printf("Sum score is %d\n", sum); 			printf("Average score is %d\n", sum / n); 			break; 		case 3: 			Scoresort(id, score, n); 			for (i = 0; i <= n - 1; i++) { 				printf("%3d%5d\n", id[i], score[i]); 			} 			break; 		case 4: 			Idsort(id, score, n); 			for (i = 0; i <= n - 1; i++) { 				printf("%3d%5d\n", id[i], score[i]); 			} 			break; 		case 5: 			printf("Input id:\n"); 			scanf("%d", &x); 			m = Selectsort(id, score, n, x); 			if (m == -1) { 				printf("查询错误\n"); 			} 			else { 				printf("----------------\n"); 				printf("id:%3d score:%3d 排名:%3d\n", id[m], score[m], m + 1); 			} 			break; 		case 6: 			Scoreclass(score, n); 			break; 		case 7: 			Showinfo(id, score, n); 			sum = Average(score, n); 			printf("----------------\n"); 			printf("Sum score is %d\n", sum); 			printf("Average score is %d\n", sum / n); 			break;   		default: 			printf("Invalid operator\n");     		} 	} } //输出分数段 void Scoreclass(int score[], int n) {  	int i, j, count, k; 	double bate, m; 	m = n; 	int begin[5] = { 0,60,70,80,90 }; 	int end[5] = { 59,69,79,89,100 }; 	char re[][10] = { "不及格","及格","中等","良好","优秀" };  	for (i = 0, j = 0; i <= n, j < 5; i++, j++) { 		count = 0; 		bate = 0; 		for (k = 0; k < n; k++) { 			if ((begin[i] <= score[k]) && (end[i] >= score[k])) { 				count += 1; 				bate = (100 * count) / m; 			}  		}  		printf("%s的学生人数为:%d ,所占百分比为%.2f\n", re[j], count, bate / 100);  	}  } //输出每个学生的学号和成绩 void Showinfo(int id[], int score[], int n) { 	int i; 	for (i = 0; i <= n - 1; i++) { 		printf("id:%3d score:%3d\n", id[i], score[i]); 	} } //根据学号查询学生成绩 int Selectsort(int id[], int score[], int n, int x) { 	int temp_score, i, j, temp_id, k; 	for (i = 0; i < n - 1; i++) { 		for (j = i + 1; j < n; j++) { 			if (score[i] < score[j]) { 				temp_score = score[i]; 				score[i] = score[j]; 				score[j] = temp_score; 				temp_id = id[i]; 				id[i] = id[j]; 				id[j] = temp_id; 			} 		} 	} 	for (k = 0; k < n; k++) { 		if (id[k] == x) 			return k;  	}return -1;     } //根据学号从小到大打印成绩 void Idsort(int id[], int score[], int n) { 	int temp_score, i, j, temp_id; 	for (i = 0; i < n - 1; i++) { 		for (j = i + 1; j < n; j++) { 			if (id[i] > id[j]) { 				temp_score = score[i]; 				score[i] = score[j]; 				score[j] = temp_score; 				temp_id = id[i]; 				id[i] = id[j]; 				id[j] = temp_id; 			} 		} 	}   } //从高到低打印成绩 void Scoresort(int id[], int score[], int n) { 	int temp_score, i, j, temp_id; 	for (i = 0; i < n - 1; i++) { 		for (j = i + 1; j < n; j++) { 			if (score[i] < score[j]) { 				temp_score = score[i]; 				score[i] = score[j]; 				score[j] = temp_score; 				temp_id = id[i]; 				id[i] = id[j]; 				id[j] = temp_id; 			} 		} 	}   } //计算班级平均分 int Average(int score[], int n) { 	int i, sum = 0; 	for (i = 0; i < n; i++) { 		sum += score[i]; 	} 	return sum; } //录入学生成绩 void Readscore(int id[], int score[], int n) {   	int i; 	for (i = 0; i < n; i++) { 		printf("Input student's id and score:"); 		scanf("%d %d", &id[i], &score[i]); 		if (score[i] < 0) { 			printf("成绩输入错误\n"); 			return; 		} 	} 	system("pause"); }  不是我自己写的，这是我们教导老师所给一个程序模板，根据模板修改一下，实现自己要求