user-0 提问: 编程序遇到问题，不会修改，求指导。3q

回复:
user: user-1
content: 楼主这个代码格式，，，，，，，，，

user: user-2
content: void k(int i,int len)  {      for(i=0; i<len; ++i)  {        printf("第%d个学生的信息是:\n", i+1);          printf("age = ", &parr[i].age);  printf("name = ", parr[i].name);  printf("score = ", &parr[i].score);   pintf("\n");  }  return;  }  看到楼主这里的printf格式我就真的不想再看下去了，建议还是先看看C语言基础

user: user-3
content: 强烈要求 楼主提高编程思想 ，此程序虽然看着小，但是 经过楼主的加工 是在让调试人员 痛不欲生 。 本着最小的改动 给你改了改！   #include <stdio.h> #include <malloc.h> typedef struct student  { 		int age; 		float score; 		char name[100]; }st;  void f(st *parr,int i,int len) {     		for(i=0; i<len; ++i) 		{ 				printf("请输入第%d个学生的信息: ", i+1); 				printf("age = "); 				scanf("%d", &parr[i].age);  				printf("name = "); 				scanf("%s", parr[i].name);  				printf("score = "); 				scanf("%f", &parr[i].score);  		} 		return; }  void g(st * parr,int len) {   		int i,j,k; 		st t; 		for (i=0; i<len-1; ++i) 		{ 				for (j=0; j<len-1-i; ++j) 				{ 						if (parr[j].score > parr[j+1].score) 						{  								t = parr[j]; 								parr[j] = parr[j+1]; 								parr[j+1] = t; 						} 				} 		} 		return; }  void k(st *parr,int len) {    		int i =0;  		for(i=0; i<len; ++i) 		{ 				printf("第%d个学生的信息是:\n", i+1); 				printf("age = %d", parr[i].age); 				printf("name = %s", parr[i].name); 				printf("score = %lf", parr[i].score);  				printf("\n"); 		} 		return; }    int main (void) { 		int len; 		int i=0 ; 		printf("请输入学生的个数：\n"); 		printf(" len = "); 		scanf("%d", &len); 		struct student *parr; 		parr = (struct student *)malloc(len * sizeof(struct student)); 		f(parr,i,len); 		g(parr,len); 		k(parr,len);  		return 0;  }

user: user-4
content: 有些变量i和t等都没定义，另外一个循环用的变量还需要作为参数传入，用意何在？   代码的风格也有很大的问题啊，我觉着得多写多练了。 这个代码不是运行错误的问题，应该直接没法运行，错误太多。

user: user-5
content: #include <stdio.h> #include <malloc.h>   struct student  {   int age;   float score;   char name[100]; }parr[50];  void  f(int len) {  int i;   for(i=0; i<len; ++i) { printf("请输入第%d个学生的信息: ", i+1); printf("age = "); scanf("%d", &parr[i].age);      printf("name = "); scanf("%s", parr[i].name);  printf("score = "); scanf("%f", &parr[i].score);  } return ; }  void g(student *parr,int len) {      int i,j; 	for (i=0; i<len-1; ++i)   {    for (j=0; j<len-1-i; ++j)    {    if(parr[j].score>parr[j+1].score)    {     student t = parr[j];    parr[j] = parr[j+1];    parr[j+1] = t;    }    }    }   return; }  void k(int len) {     for(int i=0; i<len; ++i) {      	printf("第%d个学生的信息是:\n", i+1);         printf("age = %d", &parr[i].age); printf("name = %s", parr[i].name); printf("score = %f", parr[i].score);  printf("\n"); } return; }  int main (void) {     int len; struct student * parr; printf("请输入学生的个数：\n"); scanf("%d", &len); parr = (struct student *)malloc(len * sizeof(struct student)); f(len); g(parr,len); k(len);  return 0;  } 正确的代码

user: user-5
content: #include <stdio.h> #include <malloc.h>   struct student  {   int age;   float score;   char name[100]; }parr[50];  void  f(int len) {  int i;   for(i=0; i<len; ++i) { printf("请输入第%d个学生的信息: ", i+1); printf("age = "); scanf("%d", &parr[i].age);      printf("name = "); scanf("%s", parr[i].name);  printf("score = "); scanf("%f", &parr[i].score);  } return ; }  void g(student *parr,int len) {      int i,j; 	for (i=0; i<len-1; ++i)   {    for (j=0; j<len-1-i; ++j)    {    if(parr[j].score>parr[j+1].score)    {     student t = parr[j];    parr[j] = parr[j+1];    parr[j+1] = t;    }    }    }   return; }  void k(int len) {     for(int i=0; i<len; ++i) {      	printf("第%d个学生的信息是:\n", i+1);         printf("age = ", &parr[i].age); printf("name = ", parr[i].name); printf("score = ", &parr[i].score);  printf("\n"); } return; }  int main (void) {     int len; struct student * parr; printf("请输入学生的个数：\n"); scanf("%d", &len); parr = (struct student *)malloc(len * sizeof(struct student)); f(len); g(parr,len); k(len);  return 0;  }

user: user-6
content: 楼主首先要学会看编译器提示的编译错误，先把代码编译了再说。运行不对？能运行吗？

user: user-7
content: 你的代码问题实在是多，封装的函数，用到了很多没有定义的变量，这些变量你可以设置为全局的，不然你这个是编译不过去的，自己改吧