user-0 提问: C语言综合程序设计 急！！！

回复:
user: user-1
content: 平时都是直接用的输入重定向，第一次这么做不知道对不对   #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h>  // 宏 根据某个学生的专业名判断是否对应某个专业 #define IS_PROFESSIONAL_TX(A) (strncmp(A,"通信",strlen("通信")) == 0 ) #define IS_PROFESSIONAL_WL(A) (strncmp(A,"网络",strlen("网络")) == 0) #define IS_PROFESSIONAL_WLW(A) (strncmp(A,"物联网",strlen("物联网")) == 0)  // 学生信息结构体 struct student { 	char *name; 	char *professinal_name; 	short score_english; 	short score_liner_algebra; 	short score_c_language; 	short score_all; };   // 各专业平均总成绩，学生总人数数组，枚举变量代表专业序号 enum avr_index{tx_index,wl_index,wlw_index}; short avr_score[3] = {0}; int stu_all[3] = {0};  // 读取filename指示的文件，将学生的信息从文件内容初始化到内存 // 三级指针为一个二级指针的地址，该指针在main中定义 // 二级指针的指向一段连续的地址，连续存放了一堆指向学生信息的指针的指针 // 一级指针指向学生信息结构体 int ReadStudentInfo(const char *filename, 							struct student*** pStudent) { 	FILE *fp = fopen(filename,"r"); 	if(fp == NULL) 		return -1; 	char buf[256]; 	bzero(buf,256); 	int count = 0; 	while(fgets(buf,256,fp) != NULL) 	{ 		count++; 	} 	// printf("%d\n",count); 	int i = 0; 	(*pStudent) = (struct student **) malloc (sizeof(struct student *) * count); 	for(i = 0; i < count; i++) 		(*pStudent)[i] = (struct student *) malloc(sizeof(struct student));  	fseek(fp,0,SEEK_SET); 	bzero(buf,256); 	char *buf_temp = NULL; 	char *buf_t = NULL; 	char a_temp[16]; 	bzero(a_temp,16); 	i = 0; 	int len = 0; 	while(fgets(buf,256,fp) != NULL && i < count) 	{ 		buf_t = buf; 		 		while(isspace(*buf_t))   //读取一行数据的学生名 			++buf_t; 		buf_temp = buf_t; 		while(!isspace(*buf_t)) 			buf_t++; 		len = (buf_t - buf_temp) + 1; 		(*pStudent)[i]->name = (char *)malloc(sizeof(char) * len); 		bzero((*pStudent)[i]->name,len); 		strncpy((*pStudent)[i]->name,buf_temp,len); 		// printf("=== %s\n",*pStudent[i]->name);  		while(isspace(*buf_t))   //读取一行数据的专业名 			++buf_t; 		buf_temp = buf_t; 		while(!isspace(*buf_t)) 			buf_t++; 		len = (buf_t - buf_temp) + 1; 		(*pStudent)[i]->professinal_name = (char *)malloc(sizeof(char) * len); 		bzero((*pStudent)[i]->professinal_name,len); 		strncpy((*pStudent)[i]->professinal_name,buf_temp,len); 		// printf("=== %s\n",*pStudent[i]->professinal_name);  		while(isspace(*buf_t))   //读取一行数据的英语成绩 			++buf_t; 		buf_temp = buf_t; 		while(!isspace(*buf_t)) 			buf_t++; 		len = (buf_t - buf_temp) + 1; 		bzero(a_temp,16); 		strncpy(a_temp,buf_temp,len); 		(*pStudent)[i]->score_english = atoi(a_temp);  		while(isspace(*buf_t))   //读取一行数据的线代成绩 			++buf_t; 		buf_temp = buf_t; 		while(!isspace(*buf_t)) 			buf_t++; 		len = (buf_t - buf_temp) + 1; 		bzero(a_temp,16); 		strncpy(a_temp,buf_temp,len); 		(*pStudent)[i]->score_liner_algebra = atoi(a_temp); 		 		while(isspace(*buf_t))   //读取一行数据的C成绩 			++buf_t; 		buf_temp = buf_t; 		while(isdigit(*buf_t)) 			buf_t++; 		len = (buf_t - buf_temp) + 1; 		bzero(a_temp,16); 		strncpy(a_temp,buf_temp,len); 		(*pStudent)[i]->score_c_language = atoi(a_temp);  		bzero(buf,256); 		i++; 	}   	fclose(fp); 	return count; }  // 统计各专业学生的总人数，总平均成绩，计算学生总成绩 // 三级指针为一个二级指针的地址，该指针在main中定义 // 二级指针的指向一段连续的地址，连续存放了一堆指向学生信息的指针的指针 // 一级指针指向学生信息结构体 // num为指针可以找到的学生总人数 void Count(struct student ***pStudent,int num) { 	int i = 0; 	enum avr_index index; 	for(i = 0; i < num; i++) 	{ 		(*pStudent)[i]->score_all = (*pStudent)[i]->score_english + (*pStudent)[i]->score_liner_algebra  										+ (*pStudent)[i]->score_c_language;  		if(IS_PROFESSIONAL_TX((*pStudent)[i]->professinal_name)) 			index = tx_index; 		else if(IS_PROFESSIONAL_WL((*pStudent)[i]->professinal_name)) 			index = wl_index; 	 	else if(IS_PROFESSIONAL_WLW((*pStudent)[i]->professinal_name)) 			index = wlw_index; 		else 			continue;   		stu_all[index]++; 		if(avr_score[index] == 0) 				{ 					avr_score[index] = (*pStudent)[i]->score_all; 				} 		else 		{ 			avr_score[index] += (*pStudent)[i]->score_all; 			avr_score[index] /= 2; 		}  	} }  // 打印各个学生的信息和总的统计信息 // 三级指针为一个二级指针的地址，该指针在main中定义 // 二级指针的指向一段连续的地址，连续存放了一堆指向学生信息的指针的指针 // 一级指针指向学生信息结构体 // num为指针可以找到的学生总人数 void InfoPrint(struct student ***pStudent,int num) { 	puts("学生信息:"); 	puts("___________________________"); 	printf("序号\t姓名\t专业\t英语成绩 线代成绩 C成绩 总成绩\t\n"); 	int i; 	for(i = 0; i < num; i++) 	{ 		printf("%d\t",i+1); 		printf("%s\t",(*pStudent)[i]->name); 		printf("%s\t",(*pStudent)[i]->professinal_name); 		printf("%d\t",(*pStudent)[i]->score_english); 		printf("%d\t",(*pStudent)[i]->score_liner_algebra); 		printf("%d\t",(*pStudent)[i]->score_c_language); 		printf("%d",(*pStudent)[i]->score_all); 		printf("\n"); 	} 	puts("统计信息:"); 	puts("___________________________"); 	printf("序号\t专业名称  学生人数  平均成绩\n"); 	for(i = 0; i < 3; i++) 	{ 		printf("%d\t",i+1); 		if(i == 0) 		printf("通信"); 		else if(i == 1) 		printf("网络"); 		else if(i == 2) 		printf("物联网"); 		printf("\t"); 		printf("%d\t",stu_all[i]); 		printf("%d",avr_score[i]); 		printf("\n"); 	}  }  int main(void) { 	struct student **pStudent  = (struct student **) malloc(sizeof(struct student *)); 	int count = ReadStudentInfo("a.txt",&pStudent); 	Count(&pStudent,count); 	InfoPrint(&pStudent,count);  	for   	return 0; }

user: user-2
content: 楼上正解，楼主也需要自己动动手咯。。  你看设计说明的后面还有个实验步骤呢。。。。

user: user-3
content: 这是详细设计文档了，就剩转化代码了 这个应该不是很复杂，一个一个实现试试吧