#include"stdio.h"
#include"stddef.h"
#include"stddef.h"
#include"string.h"
#define MAX 10
typedef struct student {
char name[MAX];
int num[MAX];
char sex[MAX];
int chinese;
int mathematic;
int english;
int computer;
struct student *next;
} stu;
stu *head;
void print() {
printf("\t\t\tScore Manage System\n");
printf("<8>Chinese Average\t");
printf("<10>English Average\t");
printf("<11>Computer Average\t");
}
void cin(stu *p1) {
scanf("%d", &p1
->chinese
);
scanf("%d", &p1
->mathematic
);
scanf("%d", &p1
->english
);
scanf("%d", &p1
->computer
);
}
stu *cindata() {
stu *p1, *p2;
int i = 1;
char ch;
p1
= (stu
*)malloc(sizeof(stu
));
head = p1;
while(i) {
cin(p1);
printf("Do you Want to Continue?yes or no");
if(ch == 'n' || ch == 'N') {
i = 0;
p1->next = NULL;
} else {
p2 = p1;
p1
= (stu
*)malloc(sizeof(stu
));
p2->next = p1;
}
}
return(p1->next);
}
void lookdata(stu *p1) {
while(p1 != NULL) {
printf("Name:%s\t", p1
->name
);
printf("Chinese:%d\t", p1
->chinese
);
printf("Math:%d\t", p1
->mathematic
);
printf("English:%d\t", p1
->english
);
printf("Computer:%d\t", p1
->computer
);
p1 = p1->next;
}
}
void insert(stu *p2) {
stu *p1, *p3;
char ch;
int i = 1;
p3
= (stu
*)malloc(sizeof(stu
));
p1 = p2;
while(i) {
cin(p3);
printf("Enter again?yes or no");
if(ch == 'n' || ch == 'N') {
i = 0;
p3->next = NULL;
} else {
while(p1 != NULL)
p1 = p1->next;
p3
= (stu
*)malloc(sizeof(stu
));
p1->next = p3;
}
}
}
find(stu *p2) {
char name[20];
int b = 0;
printf("Enter the name of the student you want to find:");
while(p2 != NULL) {
if(strcmp(name
, p2
->name
) == 0) {
printf("The data you want has be found\n");
printf(" Name:%s\t", p2
->name
);
printf("Chinese:%d\t", p2
->chinese
);
printf("Math:%d\t", p2
->mathematic
);
printf("English:%d\t", p2
->english
);
printf("Computer:%d\t", p2
->computer
);
b = 1;
} else if(b == 0)
p2 = p2->next;
}
if(b == 1) {
print();
} else {
print();
}
}
void caverage(stu *p2) {
stu *p1;
int i;
float max = 0.0, min = 200.0;
float sum = 0.0, aver = 0;
p1 = p2;
if(p1 == NULL)
else
for(i = 0; p1 != NULL; i++, p1 = p1->next)
sum += p1->chinese;
aver /= i;
for(i = 0; p1 != NULL; i++, p1 = p1->next)
if(max < p1->chinese)
max = p1->chinese;
for(i = 0; p1 != NULL; i++, p1 = p1->next)
if(min < p1->chinese)
min = p1->chinese;
printf("Chinese Average:%f", aver
);
printf("Chinese Max:%f", max
);
printf("Chinese Min:%f", min
);
}
void maverage(stu *p2) {
stu *p1;
int i;
float max = 0.0, min = 200.0;
float sum = 0.0, aver = 0;
p1 = p2;
if(p1 == NULL)
else
for(i = 0; p1 != NULL; i++, p1 = p1->next)
sum += p1->mathematic;
aver /= i;
for(i = 0; p1 != NULL; i++, p1 = p1->next)
if(max < p1->mathematic)
max = p1->mathematic;
for(i = 0; p1 != NULL; i++, p1 = p1->next)
if(min < p1->mathematic)
min = p1->mathematic;
printf("Math Average:%f", aver
);
}
void eaverage(stu *p2) {
stu *p1;
int i;
float max = 0.0, min = 200.0;
float sum = 0.0, aver = 0;
p1 = p2;
if(p1 == NULL)
else
for(i = 0; p1 != NULL; i++, p1 = p1->next)
sum += p1->english;
aver /= i;
for(i = 0; p1 != NULL; i++, p1 = p1->next)
if(max < p1->english)
max = p1->english;
for(i = 0; p1 != NULL; i++, p1 = p1->next)
if(min < p1->english)
min = p1->english;
printf("English avergre:%f", aver
);
printf("English Max:%f", max
);
printf("English Min:%f", min
);
}
void comaverage(stu *p2) {
stu *p1;
int i;
float max = 0.0, min = 200.0;
float sum = 0.0, aver = 0;
p1 = p2;
if(p1 == NULL)
else
for(i = 0; p1 != NULL; i++, p1 = p1->next)
sum += p1->computer;
aver /= i;
for(i = 0; p1 != NULL; i++, p1 = p1->next)
if(max < p1->computer)
max = p1->computer;
for(i = 0; p1 != NULL; i++, p1 = p1->next)
if(min < p1->computer)
min = p1->computer;
printf("Computer Averger:%f", aver
);
printf("Computer Max:%f", max
);
printf("Computer Min:%f", min
);
}
update(stu *p2) {
char name[10];
int b = 0;
while(p2 != NULL) {
if(strcmp(name
, p2
->name
) == 0) {
scanf("Name:%s", p2
->name
);
scanf("Num:%s", p2
->num
);
scanf("Sex:%s", p2
->sex
);
scanf("Chinese:%d", p2
->chinese
);
scanf("Math:%d", p2
->mathematic
);
scanf("english:%d", p2
->english
);
scanf("Computer:%d", p2
->computer
);
b = 1;
} else if(b == 0)
printf("Sorry not Find data!");
p2 = p2->next;
}
if(b == 0) {
print();
printf("Sorry not Find data!");
} else {
print();
}
}
save(stu *p2) {
FILE *fp;
char file[10];
while(p2 != NULL) {
p2 = p2->next;
}
}
char password[7] = "123456";
void main() {
int choice;
stu *p2;
char s[8];
int flag = 0, i;
int n = 3;
do {
flag = 1;
break;
} else {
printf("Error Enter again:\n");
n--;
}
} while(n > 0);
if(!flag) {
printf("you have Enter 3 times!");
}
printf("~~~~~~~~~~\t\t\t~~~~~~~~~~~~\n");
printf("\t\tWelcom to the Mis\n");
printf("Author:-----\tClass:------\tNum:------\n");
printf("%%%%%%%%%%%%%%%%%%%%%%%%%%%\n");
printf("==============\t\t==============\n");
printf("==============\t\t==============\n");
printf("\t\tEnter the MIS yes or no\n");
if(choice == 'n' || choice == 'N')
print();
while(1) {
if(i < 1 || i > 8) {
printf("Enter num from 1 to 8:\n");
}
switch(i) {
case 1:
p2 = cindata();
break;
case 2:
lookdata(head);
break;
case 3:
insert(p2);
break;
case 4:
find(head);
break;
case 5:
update(head);
break;
case 6:
save(head);
break;
case 7:
print();
break;
case 8:
caverage(head);
break;
case 9:
maverage(head);
break;
case 10:
eaverage(head);
break;
case 11:
comaverage(head);
break;
case 12:
;
case 13:
break;
}
}
}