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.

297 lines
7.9 KiB

#include<sys.h>
void studentinit(student t)
{
t.num = 0;
t.math = 0;
t.english = 0;
t.sum_score = 0;
}
int student_show_menu() //<2F><>ʾ<EFBFBD>˵<EFBFBD>
{
int i = 0;
printf("\n");
for (i = 1; i < 50; i++)
printf("*");
printf("\n");
printf("<EFBFBD><EFBFBD>ӭʹ<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ\n\n");
printf("1.<2E><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ\n");
printf("2.<2E><>ȡȫ<C8A1><C8AB>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ\n");
printf("3.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯѧ<D1AF><D1A7>\n");
printf("4.<2E><>ѧ<EFBFBD>Ų<EFBFBD>ѯѧ<D1AF><D1A7>\n");
printf("5.<2E><>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7>\n");
printf("6.<2E><><EFBFBD>ܳɼ<DCB3><C9BC><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7>\n");
printf("7.<2E><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ\n");
printf("8.ɾ<><C9BE>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ\n");
printf("0.<2E>˳<EFBFBD>ϵͳ\n\n");
for ( i = 1; i < 50; i++)
printf("*");
printf("\n");
return 0;
}
void student_input(LNode* head) //<2F><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ
{
int n=0;
int i = 0;
printf("\n<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf_s("%d", &n);
LNode* p;
LNode* r = head;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>\n");
for (i = 0; i < n; i++)
{
p = (LNode*)malloc(sizeof(LNode));
p->next = NULL;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf_s("%s", p->data.names, maxsize);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
scanf_s("%d", &p->data.num);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>");
scanf_s("%d", &p->data.math);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>Ӣ<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>");
scanf_s("%d", &p->data.english);
//int *sum = p->data.sum_score;
p->data.sum_score = p->data.math + p->data.english;
r->next = p;
r = r->next;
//free(p); //<2F><>ʹ<EFBFBD><CAB9><EFBFBD>˴˾䣬<CBBE><E4A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊÿ<CEAA><C3BF><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD><DDB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õģ<C3B5><C4A3><EFBFBD><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD>free<65><65>
printf("\n");
}
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
//return head;
}
void student_show(LNode* head) //<2F><>ȡȫ<C8A1><C8AB>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ
{
printf("\n<EFBFBD><EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡȫ<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ\n");
LNode* p;
p = head;
if (p->next == NULL)
{
printf("\n<EFBFBD><EFBFBD>ǰû<EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>¼! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>\n");
return;
}
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t\tѧ<EFBFBD><EFBFBD>\t\t<EFBFBD><EFBFBD>ѧ<EFBFBD>ɼ<EFBFBD>\tӢ<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>\t<EFBFBD>ܳɼ<EFBFBD>\t\t\n");
while (p->next != NULL)
{
p = p->next;
printf("%s\t\t%d\t\t%d\t\t%d\t\t%d\t\t\n",
p->data.names, p->data.num, p->data.math, p->data.english, p->data.sum_score);
}
}
int name_find(LNode* head, student f) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯѧ<D1AF><D1A7>
{
printf("<EFBFBD><EFBFBD>3<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯѧ<EFBFBD><EFBFBD>\n");
LNode* p;
p = head;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf_s("%s", f.names, maxsize);
while ((p->next != NULL) && strcmp(f.names, p->data.names)) //str1=str2<72><32><EFBFBD>򷵻<EFBFBD><F2B7B5BB><EFBFBD><E3A3BB>str1!=str2<72><32><EFBFBD>򷵻<EFBFBD><F2B7B5BB><EFBFBD><EFBFBD><EFBFBD>
{
p = p->next;
}
if ((p->next == NULL) && strcmp(f.names, p->data.names))
{
printf("\n<EFBFBD><EFBFBD>Ǹ<EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ! \n");
return 0;
}
else
{
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t\tѧ<EFBFBD><EFBFBD>\t\t<EFBFBD><EFBFBD>ѧ<EFBFBD>ɼ<EFBFBD>\tӢ<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>\t<EFBFBD>ܳɼ<EFBFBD>\t\t\n");
printf("%s\t\t%d\t\t%d\t\t%d\t\t%d\t\t\n",
p->data.names, p->data.num, p->data.math, p->data.english, p->data.sum_score);
return 1;
}
}
int num_find(LNode* head, student f2) //<2F><>ѧ<EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>ѧ<EFBFBD><D1A7>
{
printf("<EFBFBD><EFBFBD>4<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>Ų<EFBFBD>ѯѧ<EFBFBD><EFBFBD>\n");
LNode* p;
p = head;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
scanf_s("%d", &f2.num);
while ((p->next != NULL) && (p->data.num != f2.num))
{
p = p->next;
}
if ((p->next == NULL) && (p->data.num != f2.num))
{
printf("\n<EFBFBD><EFBFBD>Ǹ<EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ! \n");
return 0;
}
else
{
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t\tѧ<EFBFBD><EFBFBD>\t\t<EFBFBD><EFBFBD>ѧ<EFBFBD>ɼ<EFBFBD>\tӢ<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>\t<EFBFBD>ܳɼ<EFBFBD>\t\t\n");
printf("%s\t\t%d\t\t%d\t\t%d\t\t%d\t\t\n",
p->data.names, p->data.num, p->data.math, p->data.english, p->data.sum_score);
return 1;
}
}
void num_seq(LNode* head) //<2F><>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
printf("\n<EFBFBD><EFBFBD>5<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>\n");
LNode* newhead, * rear;
newhead = head->next;
rear = NULL;
if (newhead == NULL || newhead->next == NULL)
{
printf("\n<EFBFBD><EFBFBD>ǰû<EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>¼! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>\n");
return;
}
while (newhead != rear)
{
while (newhead->next != rear)
{
if (newhead->data.num > newhead->next->data.num)
{
int temp = newhead->data.num;
newhead->data.num = newhead->next->data.num;
newhead->next->data.num = temp;
int temp1 = newhead->data.math;
newhead->data.math = newhead->next->data.math;
newhead->next->data.math = temp1;
int temp2 = newhead->data.english;
newhead->data.english = newhead->next->data.english;
newhead->next->data.english = temp2;
int temp3 = newhead->data.sum_score;
newhead->data.sum_score = newhead->next->data.sum_score;
newhead->next->data.sum_score = temp3;
//char temp4_str = gets(newhead->data.names, sizeof(char));
//char *temp4 = newhead->data.names; //<2F><><EFBFBD><EFBFBD>˴<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>ʵڶ<CAB5><DAB6><EFBFBD>strcpyʹ<79><CAB9>*temp4<70>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ˡ<EFBFBD>
student str;
strcpy_s(str.names, maxsize, newhead->data.names);
//gets_s(newhead->data.names,maxsize);
//newhead->data.names = newhead->next->data.names;
strcpy_s(newhead->data.names, maxsize, newhead->next->data.names);
//newhead->next->data.names = temp4;
strcpy_s(newhead->next->data.names, maxsize, str.names);
}
newhead = newhead->next;
}
rear = newhead;
newhead = head->next;
}
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t\tѧ<EFBFBD><EFBFBD>\t\t<EFBFBD><EFBFBD>ѧ<EFBFBD>ɼ<EFBFBD>\tӢ<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>\t<EFBFBD>ܳɼ<EFBFBD>\t\t\n");
while (head->next != NULL)
{
head = head->next;
printf("%s\t\t%d\t\t%d\t\t%d\t\t%d\t\t\n",
head->data.names, head->data.num, head->data.math, head->data.english, head->data.sum_score);
}
}
void sum_seq(LNode* head) //<2F><><EFBFBD>ܳɼ<DCB3><C9BC><EFBFBD><EFBFBD><EFBFBD>
{
printf("\n<EFBFBD><EFBFBD>6<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>\n");
LNode* newhead, * rear;
newhead = head->next;
rear = NULL;
if (newhead == NULL || newhead->next == NULL)
{
printf("\n<EFBFBD><EFBFBD>ǰû<EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>¼! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>\n");
return;
}
while (newhead != rear)
{
while (newhead->next != rear)
{
if (newhead->data.sum_score < newhead->next->data.sum_score)
{
int temp = newhead->data.num;
newhead->data.num = newhead->next->data.num;
newhead->next->data.num = temp;
int temp1 = newhead->data.math;
newhead->data.math = newhead->next->data.math;
newhead->next->data.math = temp1;
int temp2 = newhead->data.english;
newhead->data.english = newhead->next->data.english;
newhead->next->data.english = temp2;
int temp3 = newhead->data.sum_score;
newhead->data.sum_score = newhead->next->data.sum_score;
newhead->next->data.sum_score = temp3;
student str;
strcpy_s(str.names, strlen(newhead->data.names) + 1, newhead->data.names);
strcpy_s(newhead->data.names, strlen(newhead->next->data.names) + 1, newhead->next->data.names); //ע<><EFBFBD><E2BBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD>strlen()<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD><EFBFBD>'\0<><30>
strcpy_s(newhead->next->data.names, strlen(str.names) + 1, str.names);
}
newhead = newhead->next;
}
rear = newhead;
newhead = head->next;
}
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t\tѧ<EFBFBD><EFBFBD>\t\t<EFBFBD><EFBFBD>ѧ<EFBFBD>ɼ<EFBFBD>\tӢ<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>\t<EFBFBD>ܳɼ<EFBFBD>\t\t\n");
while (head->next != NULL)
{
head = head->next;
printf("%s\t\t%d\t\t%d\t\t%d\t\t%d\t\t\n",
head->data.names, head->data.num, head->data.math, head->data.english, head->data.sum_score);
}
}
void stu_insert(LNode* head, student in) //<2F><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ
{
printf("\n<EFBFBD><EFBFBD>7<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf_s("%s", in.names, maxsize);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
scanf_s("%d", &in.num);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>");
scanf_s("%d", &in.math);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>Ӣ<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>");
scanf_s("%d", &in.english);
in.sum_score = in.math + in.english;
LNode* stu, * r;
r = head;
int d, dp = 0;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD>");
scanf_s("%d", &d);
while ((r != NULL) && (dp < d - 1))
{
r = r->next;
dp = dp + 1;
}
if (r == NULL)
{
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
return;
}
stu = (LNode*)malloc(sizeof(LNode));
stu->data = in;
stu->next = r->next;
r->next = stu;
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
}
void stu_del(LNode* head, student* dl) //ɾ<><C9BE>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ
{
printf("\n<EFBFBD><EFBFBD>8<EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ\n");
LNode* stu, * r;
r = head;
int d, dp = 0;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD>");
scanf_s("%d", &d);
while ((r->next != NULL) && (dp < d - 1))
{
r = r->next;
dp++;
}
if (r->next == NULL)
{
printf("\nɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
return;
}
stu = r->next;
r->next = stu->next;
*dl = stu->data; //<2F><>ʱӦΪ*dl ,<2C><><EFBFBD><EFBFBD>printf<74><66><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
free(stu);
printf("ɾ<EFBFBD><EFBFBD>%s<>ɹ<EFBFBD>!\n", dl->names);
//return;
}