Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Help! Help to modify the curriculum design of C language.
Help! Help to modify the curriculum design of C language.
I hope it helps you.

Related information:

One made in C language: student achievement statistical system

/* 1 1.3.2 source program */

/* * * * * * * * * * * * xuesheng . c * * * * * * * * * */

/* * * * header file (. h)* * * * * * * */

#include "stdio.h" /*I/O function */

#include "stdlib.h" /* Other notes */

#include "string.h" /* string function */

# includes "conio.h"/* screen operation function */

#include "mem.h" /* Memory operation function */

#include "ctype.h" /* character manipulation function */

#include "alloc.h" /* Dynamic address assignment function */

# define n 3/* Define constant */

Typedef struct z 1 /* define data structure */

{

Character number [11];

char name[ 15];

int score[N];

Floating sum;

Floating average;

Int order;

struct z 1 * next;

} students;

/* The following is the function prototype */

Student * init (); /* Initialization function */

Student * create (); /* Create a linked list */

Student * Delete (student * h); /* Delete record */

Invalid printing (student * h); /* Show all records */

Void search (student * h); /* Find */

Void save (student * h); /* Save */

Student * load (); /* Read in record */

Void computer (student * h); /* Calculate the total score and average score */

Student * insert (student * h); /* Insert record */

void append(); /* Additional records */

void copy(); /* Copy files */

Student * sorting (student * h); /* Sort */

Student * index (student * h); /* Index */

Void total (student * h); /* Total by category */

int menu _ select(); /* Menu function */

/* * * * * Main function starts * * * * *

Master ()

{

int I;

Student * head; /* Linked list definition header pointer */

head = init(); /* Initialize linked list */

clr SCR(); /* Clear the screen */

for(; ; )/* infinite loop */

{

Switch(menu_select()) /* Calls the main menu function and returns an integer as the condition of the switch statement */

The value of {/* is different, and the function executed is different. Break cannot be omitted */

Case 0: head = init (); Break; /* Perform initialization */

case 1:head = create(); Break; /* Create a linked list */

Case 2: head=delete (head); Break; /* Delete record */

Case 3: printing (header); Break; /* Show all records */

Case 4: Search (header); Break; /* Find records */

Case 5: rescue (head); Break; /* Save the file */

Situation 6: head = load (); Break; /* Read file */

Case 7: computer (head); Break; /* Calculate the total score and average score */

Case 8: head = insert (head); Break; /* Insert record */

Case 9: copy (); Break; /* Copy files */

Case10: head = sort (head); Break; /* Sort */

case 1 1:append(); Break; /* Additional records */

Case 12:head=index (head); Break; /* Index */

Case 13: Total (header); Break; /* Total by category */

Case 14: exit (0); /* If the menu return value is 14, the program ends */

}

}

}

/* menu function, the return value is integer */

menu_select()

{

Char * menu [] = {* * * * * * * * menu * * * * * * * * * * * * * * * * * * * * *,/* defines the menu string array */

"0. Initialize list", /* Initialize */

"1. input list",/* input record */

"2. Delete the record from the list",/* Delete the record from the table */

"3. Print list",/* Displays all records in the single linked list */

"4. Search records by name",/* Find records by name */

"5. Save the file",/* Save the records in the single linked list to a file */

"6. Load the file",/* Read the record from the file */

"7. Calculate scores",/* Calculate the total score and average score of all students */

"8. Insert the record into the list",/* Insert the record into the table */

"9. Copy the file to a new file"./* Copy the file */

"10. Sort to generate a new file", /* Sort */

"1 1. Append record to file",/* Append record to file */

"12. Index on number", /* index */

"13. Total figures",/* Total by category */

"14. Exit"}; /* Exit */

char s[3]; /* Save the selection number in character form */

int c,I; /* Define an integer variable */

gotoxy( 1,25); /* Move the cursor */

Printf ("Press any key to enter the menu ... \ n"); /* Press any key to enter the main menu */

getch(); /* Enter any key */

clr SCR(); /* Clear the screen */

gotoxy( 1, 1); /* Move the cursor */

Textcolor (yellow); /* Set the text display color to yellow */

Textbackground (blue); /* Set the background color to blue */

gotoxy( 10,2); /* Move the cursor */

putch(0xc 9); /* Output the upper left corner border ┏ */

for(I = 1; I & lt44; i++)

putch(0x CD); /* Output the top border horizontal line */

putch(0x bb); /* Output the upper right corner border ┓ */

for(I = 3; I & lt20; i++)

{

gotoxy( 10,I); putch(0x ba); /* Output left vertical line */

gotoxy(54,I); putch(0x ba);

}/* Output right vertical line */

gotoxy( 10,20); putch(0x c8); /* Output the upper left corner border ┗ */

for(I = 1; I & lt44; i++)

putch(0x CD); /* Output bottom border horizontal line */

putch(0x BC); /* Output the lower right corner border ┛ */

Window (1 1, 3,53,19); /* Make a window showing menus, and the size of the window is designed according to the number of menus */

clr SCR(); /* Clear the screen */

for(I = 0; I< 16; I++) /* Output main menu array */

{

gotoxy( 10,I+ 1);

Cprintf("%s ",menu);

}

Textbackground (black); /* Set the background color to black */

Window (1, 1, 80, 25); /* Restore the original window size */

gotoxy( 10,2 1); /* Move the cursor */

Do {

Printf ("\ nEnter your choice (0 ~14):"); /* Display prompt information outside the menu window */

scanf("%s ",s); /* Enter options */

c = atoi(s); /* Convert the input string into an integer */

} while(c & lt; 0 | | c >; 14); /* The selected item is not between 0 and 14. Please re-enter */

Return to c; /* Returns the option, and the main program calls the corresponding function according to the number */

}

Student *init ()

{

Returns NULL

}

/* Create a linked list */

Student * Create ()

{

int I; int s;

STUDENT *h=NULL, * info/* student pointer to structure */

for(; ; )

{

Info= (student *)malloc(sizeof)); /* Apply for space */

If (! Info) /* If the pointer information is empty */

{

Printf(" \ n Out of memory "); /* Output memory overflow */

Return NULL/* Return null pointer */

}

Enter ("input number:", information-> No,11); /* Enter the student number and check */

if(info-& gt; There is no [0]=='@') delimiter; /* If the first character of the student number is @, the input is over */

Enter ("Enter name:", information-> Name,15); /* Enter the name and check */

Printf ("Please enter %d score \n", n); /* Prompt to start entering scores */

s = 0; /* Calculate the total score of each student, with an initial value of 0*/

for(I = 0; I & ltn;; I++) /*N courses are circulated n times */

{

Do {

Printf ("score %d:", I+1); /* Prompt which course to attend */

Scanf("%d ",& Info-> Score); /* Enter the score */

if(info-& gt; Score & gt 100 | | Information->; Score & lt0) /* Make sure the score is between 0~ 100 */

Printf ("bad data, repeated input \ n"); /* Error message */

} while(info-& gt; Score & gt 100 | | Information->; Score & lt0);

s = s+info-& gt; Scores; /* Accumulate the scores of various courses */

}

Information-> sum = s; /* Save the total score */

Information-> Average value = (floating point) signal-to-noise ratio; /* Average */

Information-> Order = 0; /* The value before sorting is 0 */

Information-> next = h; /* Take the first node as the successor of the new input node */

H = info/* The new input node is the new head node */

}

Return (h); /* Return the head pointer */

}

/* Enter a string and verify its length */

Input (char * prompt, char *s, int count)

{

char p[255];

Do {

Printf (prompt); /* Display prompt information */

scanf("%s ",p); /* Enter the string */

If(strlen(p)>count)printf("\n too long! \ n "); /* Check the length, and then re-enter */

}while(strlen(p) > count);

strcpy(s,p); /* Copy the input string to the string s */

}

/* Output the node information in the linked list */

Invalid print (student *h)

{

int I = 0; /* Number of statistical records */

Student * p;; /* Move the pointer */

clr SCR(); /* Clear the screen */

p = h; /* The initial value is the head pointer */

printf(" \ n \ n \ n * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");

printf(" | rec | nO | name | sc 1 | sc2 | sc3 | sum | ave | order | \ n ");

printf(" |-|-|-|-|-|-|-|-|-|-| \ n ");

And (p! = empty)

{

i++;

printf(" | % 3d | %- 10s | %- 15s | % 4d | % 4d | % 4d | % 4.2f | % 4.2f | % 3d | \ n ",I,p-& gt; No, P-> Name, p-> Score [0], p-> Score [1],

p->; Score [2], p-> Sum, p- > average, p->; Order);

p = p-& gt; Next;

}

printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * end * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");

}

/* Delete record */

Student * Delete (student *h)

{

Students *p, * q;; /*p is the node pointer to be deleted, and q is its predecessor pointer */

char s[ 1 1]; /* Store student number */

clr SCR(); /* Clear the screen */

Printf ("Please delete no \ n"); /* Display prompt information */

scanf("%s ",s); /* Enter the student number of the record to be deleted */

q = p = h; /* Assign initial values to q and p */

while(strcmp(p-& gt; No, s)&; & ampp! =NULL) /* When the recorded student number is not what you are looking for, or the pointer is not empty */

{

q = p; /* Assign the P pointer value to Q as the predecessor pointer of P */

p = p-& gt; Next; /* Point the P pointer to the next record */

}

If(p==NULL) /* If p is empty, the node is not in the linked list */

printf("\nlist no %s student\n ",s);

Else /*p is not empty, showing the found record information */

{

Printf ("* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n").

printf(" | no | name | sc 1 | sc2 | sc3 | sum | ave | order | \ n ");

printf(" |-|-|-|-|-|-|-|-|-| \ n ");

printf(" | %- 10s | %- 15s | % 4d | % 4d | % 4d | % 4.2f | % 4.2f | % 3d | \ n ",p-& gt; I don't know,

p->; Name, p-> Score [0], p-> Score [1], p-> Score [2], p-> Sum,

p->; Average value, p-> Order);

printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * end * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");

getch(); /* After pressing any key, delete */

If(p==h) /* If p==h, the deleted node is the head node */

h = p-& gt; Next; /* Modify the head pointer to point to the next record */

other

q->; next = p-& gt; Next; /* is not a head pointer, and the successor node of P is regarded as the successor node of Q */

Free (p); /* Release the node space indicated by p */

Printf("\n %s students were not deleted \n ",s);

Printf ("Don't forget to save \ n"); /* Don't forget to save the file after deletion */

}

Return (h); /* Return the head pointer */

}

Other related:

/% BB % AA % C4 % CF % D0 % a 1% d 1% BC/blog/item/a5b F6 e 10 e0d 2d 1042 13 F2 ECD . html

C language description of the source code for statistical students' grades

For reference only, please learn by yourself.

I hope it helps you.