C Language Project-instructor information/Student Achievement Management System

Source: Internet
Author: User










The following code is pasted: void add_tea (Teacher tea []) {int I = 0, j, num; char str [5]; if (numtea! = 0) {printf ("cover the current record? (Y/n) \ n "); gets (str); if (str [0] = 'y' | str [0] = 'y ') I = 0; else I = numtea;} printf ("Please input the number of you add the teachers:"); scanf ("% d", & num ); if (I = 0) numtea = num; else numtea + = num; if (numtea> lens) {lens + = 10; tea = (Teacher *) realloc (tea, lens * SIZE);} printf ("Please input the teacher's info: \ n"); for (; I <numtea; I ++) {getchar (); printf ("please input the teacher's NO.: "); gets (tea. number); pri Ntf ("please input the teacher's name:"); gets (tea. name); printf ("please input the teacher's sex (man/woman 0/1):"); gets (tea. sex); if (tea. sex [0] = '0') strcpy (tea. sex, "man"); else strcpy (tea. sex, "woman"); printf ("please input the teacher's address:"); gets (tea. addr); printf ("the teacher is married (No/yes0/1):"); gets (tea. married); if (tea. sex [0] = '0') strcpy (tea. sex, "No"); else strcpy (tea. sex, "Yes ") ;} Display_tea (tea, 0, numtea-1); getchar ();} void display_tea (Teacher tea [], int n1, int n2) {int I; char str [2]; if (numtea = 0) {printf ("There is Nothing! \ N "); printf (" Do you want to open some file to find the record? (Y/N) \ n "); gets (str); if (str [0] = 'y' | str [0] = 'y ') {openfileTXT (tea) ;}else {return ;}} else {for (I = n1; I <= n2; I ++) printf ("number: % s \ tname: % s \ t \ tsex: % s \ t \ taddr: % s \ t \ tmarried: % s \ t ", tea. number, tea. name, tea. sex, tea. addr, tea. married) ;}} void adjust (Teacher tea []) {char str [5]; int I =-1, j; if (numtea = 0) {printf ("there is nothing !!! \ N "); return;} while (I <0) {I = find_tea (tea); if (I> = 0) {printf (" Delete it? (Y/n) "); gets (str); if (str [0] = 'y' | str [0] = 'y ') {delete_tea (tea, I);/* count (stud); */} else {printf ("Adjust it? (Y/n) "); gets (str); if (str [0] = 'y' | str [0] = 'y ') {printf ("Please input something you want: \ n"); printf ("please input the teacher's NO.: "); gets (tea. number); printf ("please input the teacher's name:"); gets (tea. name); printf ("please input the teacher's sex (man/woman 0/1):"); gets (tea. sex); if (tea. sex [0] = '0') strcpy (tea. sex, "man"); else strcpy (tea. sex, "woman"); printf ("please input the teacher's ad Dress: "); gets (tea. addr); printf ("the teacher is married (No/yes0/1):"); gets (tea. married); if (tea. sex [0] = '0') strcpy (tea. sex, "No"); else strcpy (tea. sex, "Yes");}/* count (stud); */} display_tea (tea, 0, numtea-1);} printf ("Again to Adjust it? (Y/n) \ n "); gets (str); if (str [0] = 'y' | str [0] = 'y ') I =-1; else I = 1 ;}} int find_tea (Teacher tea []) {char str [10]; int I; if (numtea = 0) {printf ("There is nothing \ n"); return-1;} else {printf ("what do you want your fashion? \ N1.number \ t2.name \ t3.addr \ n "); gets (str); if (str [0] = '1') {printf (" please input the teacher's number: "); gets (str); for (I = 0; I <= numtea; I ++) if (strcmp (str, tea. number) = 0) {display_tea (tea, I, I); break;} else continue;} else if (str [0] = '2 ') {printf ("please input the teacher's name:"); gets (str); for (I = 0; I <= numtea; I ++) if (strcmp (str, tea. name) = 0) {display_tea (tea, I, I); break;} else continue;} e Lse if (str [0] = '3') {printf ("please input the teacher's address:"); gets (str); for (I = 0; I <= numtea; I ++) if (strcmp (str, tea. addr) = 0) {display_tea (tea, I, I); break;} else continue;} if (I> numtea) {printf ("Nothing has find \ n"); return-1 ;}return I ;}void delete_tea (Teacher tea [], int I) {int j; while (I> = 0) {for (j = I; j <numtea; j ++) tea [j] = tea [j + 1]; numtea --; printf ("Delete Success! \ N ") ;}} int writetoTXT (Teacher tea []) {int I = 0, j; FILE * fp; char filename [20]; printf ("Please input the file's name:"); gets (filename); fp = fopen (filename, "w"); fprintf (fp, "% d \ n", numtea); while (I <numtea) {fprintf (fp, "% s", tea. number, tea. name, tea. sex, tea. addr, tea. married); I ++;} fclose (fp); printf ("Save success !!! \ N "); display_tea (tea, 0, numtea-1); numtea = 0; return 0;} int openfileTXT (Teacher tea []) {int I = 0, j; FILE * fp; char filename [20], str [2]; if (numtea! = 0) {printf ("There has some records, Do you want to save them? (Y/n) "); gets (str); if (str [0] = 'y' | str [0] = 'y ') writetoTXT (tea);} printf ("Please input the file name:"); gets (filename); numtea = 0; if (fp = fopen (filename, "rb +") = NULL) {printf ("Sorry, can't open the file \ n"); return (-1);} fscanf (fp, "% d", & numtea); fgetc (fp); while (I <numtea) {fscanf (fp, "% s", & tea. number); fscanf (fp, "% s", & tea. name); fscanf (fp, "% s", & tea. sex); fscanf (fp, "% s", & tea. addr); fscanf (fp, "% S ", & tea. married); I ++;} fclose (fp); printf (" Read the file success \ n "); printf (" Display the record? (Y/n) "); gets (str); if (str [0] = 'y' | str [0] = 'y') display_tea (tea, 0, numtea-1); return (0);} void displayTheSystemInfo () {printf ("\ t Producer: \ n"); printf (" http://www.shengshiyouxi.com "); Printf (" \ n ");}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.