You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
tong tong zhang 513ad510ae
使数据按升序排序
2 years ago
.gitignore Initial commit 2 years ago
L.文件管理系统 Add L.文件管理系统 2 years ago
LICENSE Initial commit 2 years ago
README.md ztt主函数 2 years ago
hello.md 1 2 years ago
hello1.md 计算每门课程的总分和平均分 2 years ago
hello2.md 按选择法将数组num的元素值按从低到高排序 2 years ago
hello3.md 按学号查找学生成绩并显示查找结果 2 years ago
lyx.10.md lyx10 2 years ago
lyx.md lyx 2 years ago
lyx6.md lyx6 2 years ago
lyx16.md lyx16 2 years ago
readme1.md 报告 2 years ago
ztt1.md ztt1 2 years ago
ztt2.md 使数据按升序排序 2 years ago
ztt5.md 使数据按升序排序 2 years ago
ztt9.md 交换两个字符串 2 years ago
按学号查找成绩 Add 按学号查找成绩 2 years ago

README.md

System

#学生成绩管理系统代码

多个函数的使用

利用结构体

下面是代码库


#include  <stdio.h>
#include  <stdlib.h>
#include  <string.h>
#define   MAX_LEN  10                    	// 字符串最大长度 
#define   STU_NUM 30                       // 最多的学生人数 
#define   COURSE_NUM 6                     // 最多的考试科目数 
typedef struct student
{
		long num;						// 每个学生的学号 
		char name[MAX_LEN];            	// 每个学生的姓名 
		float score[COURSE_NUM];		// 每个学生COURSE_NUM门功课的成绩 
		float sum;                   	     // 每个学生的总成绩 
		float aver;               	     // 每个学生的平均成绩 
}STU;
int   Menu(void);
void  ReadScore(STU stu[], int n, int m);
void  AverSumofEveryStudent(STU stu[], int n, int m);
void  AverSumofEveryCourse(STU stu[], int n, int m);
void  SortbyScore(STU stu[],int n,int m,int (*compare)(float a,float b));
int   Ascending(float a, float b);
int   Descending(float a, float b);
void  SwapFloat(float *x, float *y);
void  SwapLong(long *x, long *y);
void  SwapChar(char x[], char y[]);
void  AsSortbyNum(STU stu[], int n, int m);
void  SortbyName(STU stu[], int n, int m);
void  SearchbyNum(STU stu[], int n, int m);
void  SearchbyName(STU stu[], int n, int m);
void  StatisticAnalysis(STU stu[], int n, int m);
void  PrintScore(STU stu[], int n, int m);
void  WritetoFile(STU record[], int n, int m);
void  ReadfromFile(STU record[], int *n, int *m);
int main(void)
{
	char  ch;
	int   n = 0, m = 0;
	STU   stu[STU_NUM];	
printf("Input student number(n<%d):", STU_NUM);
	scanf("%d", &n);
printf("Input course number(m<=%d):",COURSE_NUM);
	scanf("%d", &m);
	while (1)
	{
		ch = Menu();					    // 显示菜单,并读取用户输入 		
		switch (ch)
		{
			case 1:ReadScore(stu, n, m);
					break;
			case 2: AverSumofEveryCourse(stu, n, m);                        
					break;
            case 3: AverSumofEveryStudent(stu, n, m);                    
					break;
			case 4: SortbyScore(stu, n, m, Descending);
					printf("\nSort in descending order by score:\n");
					PrintScore(stu, n, m);
					break;
			case 5: SortbyScore(stu, n, m, Ascending);
					printf("\nSort in ascending order by score:\n");
					PrintScore(stu, n, m);
					break;
			case 6: AsSortbyNum(stu, n, m);
					printf("\nSort in ascending order by number:\n");
					PrintScore(stu, n, m);
					break;
			case 7: SortbyName(stu, n, m);
					printf("\nSort in dictionary order by name:\n");
					PrintScore(stu, n, m);
					break;
			case 8: SearchbyNum(stu, n, m);
					break;
			case 9: SearchbyName(stu, n, m);
					break;
			case 10: StatisticAnalysis(stu, n, m);
					break;
			case 11:PrintScore(stu, n, m);
					break;
case 12:WritetoFile(stu, n, m);
				     break;
			case 13:ReadfromFile(stu, &n, &m);
				     break;
			case 0: printf("End of program!");
			       	exit(0);
			default:printf("Input error!");
		}
	}
	return 0;}
//  函数功能:显示菜单并获得用户键盘输入的选项 
int Menu(void)
{
		int itemSelected;
		printf("Management for Students' scores\n");
		printf("1.Input record\n");
		printf("2.Calculate total and average score of every course\n");
		printf("3.Calculate 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("12.Write to a file\n");
		printf("13.Read from a file\n");
		printf("0.Exit\n");
		printf("Please Input your choice:");
		scanf("%d", &itemSelected); 	// 读入用户输入 
		return itemSelected;
}