A simple student grade management program

zhaozj2021-02-16  48

#include

#include

Struct List {

Int Num;

CHAR Name [256];

Int china;

Int English;

Int math;

Struct List * Next;

}

Typedef struct list node;

TypeDef node * link;

Printf_list (link head)

{

Link Pointer;

Pointer = HEAD;

While (Pointer! = NULL)

{

Printf ("Number:% D / N", Pointer-> Num);

Printf ("Name:% S / N", Pointer-> Name);

Printf ("China:% D / N", Pointer-> China);

Printf ("ENGLISH:% D / N", Pointer-> ENGLISH

Printf ("Math:% D / N", Pointer-> Math);

Pointer = POINTER-> NEXT;

}

}

Link Creat_List (Link Head)

{

int CNUM;

Char CNAME [256];

Int cchina;

int CENGLISH;

Int cmath;

LINK POINTER, NEW;

INT I;

HEAD = (link) Malloc (sizeof (node));

IF (head == null)

{Printf ("Memory Allocate Failure !! / N");

exit (0);

Else {

Printf ("Please Input Number:");

Scanf ("% D", & cnum);

Printf ("Please Input Name:");

Scanf ("% s", & cname);

Printf ("Please Input China:");

Scanf ("% d", & cchina);

PRINTF ("" please input English: ");

Scanf ("% D", & CENGLISH);

PRINTF ("Please Input Math:");

Scanf ("% d", & cmath);

Head-> Num = CNUM;

For (i = 0; i <256; i )

{

Head-> name [i] = cname [i];

}

HEAD-> China = cchina;

HEAD-> English = CENGLISH;

HEAD-> Math = CMATH;

HEAD-> next = NULL;

Pointer = HEAD;

While (1)

{

NEW = (link) Malloc (sizeof (node));

IF (new == NULL) {

Printf ("Memory Allocate Failure !! / N");

exit (0);

Printf ("Please Input Number:");

Scanf ("% D", & cnum);

IF (cnum == 0) {

Break;

Printf ("Please Input Name:");

Scanf ("% s", cname);

Printf ("Please Input China:"); Scanf ("% D", & Cchina);

PRINTF ("" please input English: ");

Scanf ("% D", & CENGLISH);

PRINTF ("Please Input Math:");

Scanf ("% d", & cmath);

NEW-> Num = CNUM;

For (i = 0; i <256; i ) {

New-> name [i] = CNAME [I];

NEW-> China = cchina;

NEW-> English = CENGLISH;

NEW-> Math = CMATH;

NEW-> next = null;

Pointer-> Next = New;

Pointer = New;

}

}

Return head;

}

Search_chengji (int Key1, Link HEAD)

{

Link Pointer;

Pointer = HEAD;

While (Pointer! = NULL)

{

IF (Pointer-> Num == KEY1)

{

Printf ("Number:% D / N", Pointer-> Num);

Printf ("Name:% S / N", Pointer-> Name);

Printf ("China:% D / N", Pointer-> China);

Printf ("ENGLISH:% D / N", Pointer-> ENGLISH

Printf ("Math:% D / N", Pointer-> Math);

}

Pointer = POINTER-> NEXT;

}

}

LINK MODIFY_CHENGJI (Link Head, Int Key3)

{

Link Pointer;

Char xname [256];

Int xchina;

INT Xenglish;

Int xmath;

Int Choose, I;

Pointer = HEAD;

Printf ("Enter 0 EXIT MODEFIY / N");

Printf ("Enter 1 Modefiy Name / N);

Printf ("Enter 2 Modefiy China / N);

Printf ("Enter 3 Modefiy ENGLISH / N");

Printf ("Enter 4 Modfiy Math / N);

Scanf ("% d", & choose);

Switch (chaoose)

{

Case 1:

Printf ("Please Input Name:");

Scanf ("% s", & xname);

Break;

Case 2:

Printf ("Please Input China:");

Scanf ("% d", & xchina);

Break;

Case 3:

PRINTF ("" please input English: ");

Scanf ("% d", & xenglish;

Break;

Case 4:

PRINTF ("Please Input Math:");

Scanf ("% D", & xmath);

Break;

}

While (1) {

Pointer = POINTER-> NEXT;

IF (Pointer-> Num == KEY3) {

IF (chaoose == 1)

{For (i = 0; i <256; i )

{

Pointer-> Name [i] = xname [i];

}

Break;

}

Else if (choose == 2)

{Pointer-> China = xChina;

Break;

Else if (choose == 3)

{Pointer-> English = XenGLish;

Break;

}

Else IF (choose == 4)

{Pointer-> Math = XMath;

Break;

}

}

Return head;

}

Link Delete_chengji (Link Head, Int Key2)

{

Link Pointer;

Link back;

Pointer = HEAD;

While (1)

{

IF (Head-> Num == KEY2)

{Head = POINTER-> NEXT;

FREE (POINTER);

Break;

}

Back = POINTER;

Pointer = POINTER-> NEXT;

IF (Pointer-> Num == KEY2)

{

Back-> next = POINTER-> Next;

FREE (POINTER);

Break;

}

Return head;

}

Link Insert_chengji (Link Head, Link New, INT Key3)

{

Link Pointer;

Pointer = HEAD;

While (1)

{

IF (Pointer == NULL) {

NEW-> next = Head;

HEAD = New;

Break;

IF (Pointer-> Num == KEY3) {

NEW-> Next = Pointer-> Next;

Pointer-> Next = New;

Break;

Pointer = POINTER-> NEXT;

}

Return head;

}

Pingjufen (Link Head)

{

Link Pointer;

Int PChina, PPChina;

INT penglish, ppenglish;

INT PMATH, PPMATH;

INT country;

PChina = 0;

PenGlish = 0;

Pmath = 0;

Count = 0;

Pointer = HEAD;

While (1)

{

PChina = PChina Pointer-> China;

Penglish = penglish pointer-> English;

Pmath = pmath pointer-> math;

Count = count;

IF (Pointer-> Next == NULL)

{

Break;

}

Pointer = POINTER-> NEXT;

}

PpChina = pchina / count;

Ppenglish = penglish / count;

PPMATH = Pmath / Count;

Printf ("China Ping Jun Fen:% D / N", PPChina);

Printf ("English Ping Jun Fen:% D / N", PPENGLISH);

Printf ("Math Ping Jun Fen:% D / N", PPMATH);

Main ()

{

For (;;)

{

Link head;

Link new;

Int key;

Int keynum;

Printf ("0> EXIT The Programm./N");

Printf ("1> CREATE LIST./N);

Printf ("2> Search Chengji./N");

Printf ("3> MODIFY CHENGJI./N");

Printf ("4> delete Chengji./N");

Printf ("5> Add Chengji./N");

Printf ("6> pingjunfeng./n");

Printf ("7> Print Chengji./N");

Scanf ("% d", & key);

Switch (key) {

Case 0:

exit (0);

Case 1:

HEAD = Creat_List (HEAD);

IF (Head! = null)

{Printf_List (HEAD);

Break;

Case 2:

Printf ("Please Input 0 EXIT./N");

PRINTF ("" ""); ");

Scanf ("% D", & keynum);

IF (Keynum == 0) {

Break;

Search_chengji (Keynum, Head);

Break;

Case 3:

Printf ("please input number for modify:");

Scanf ("% D", & keynum);

Head = modify_chengji (head, keynum);

IF (Head! = null)

{

Printf_list (hEAD);

}

Break;

Case 4:

Printf ("Please Input 0 exit / n");

PRINTF ("" "" ");

Scanf ("% D", & keynum);

IF (Keynum == 0) {

Break;

Head = delete_chengji (head, keys);

Break;

Case 5:

IF (Head! = null) {

NEW = (link) Malloc (sizeof (node));

Printf ("Please Input Number:");

Scanf ("% d", & new-> num);

IF (new-> Num == 0) {

Break;

Printf ("Please Input Name:");

Scanf ("% s", & new-> name);

Printf ("Please Input China:");

Scanf ("% D", & new-> China);

PRINTF ("" please input English: ");

Scanf ("% D", & new-> English);

PRINTF ("Please Input Math:");

Scanf ("% d", & new-> math);

Printf ("Please Input The Data Number for Insert:"); Scanf ("% D", & Keynum);

Head = INSERT_CHENGJI (HEAD, New, Keynum);

IF (Head! = null) {

Printf_list (hEAD);

}

Break;

Case 6:

Pingjufen (HEAD);

Break;

Case 7:

Printf_list (hEAD);

Break;

}

}

}

Give the program to run in TC2.0.

转载请注明原文地址:https://www.9cbs.com/read-26977.html

New Post(0)