Student Management System

Source: Internet
Author: User

 #include <stdio.h> #include <stdlib.h> #include <math.h> #include <malloc.h> #define MAX  100typedef int elemtype;typedef int eleminfo;typedef struct{elemtype num;//study number Elemtype CLS;//class char* name; Name Elemtype score[10];  Score}stuinfo;typedef struct{stuinfo stu[max];elemtype length; Number of stores}stutype;void DisplayMenu () {//Select menu printf ("menu\n");p rintf ("---------************************************ ---------\ n ");p rintf ("---------* * *. Bulk input Student information *---------\ n ");p rintf ("---------. Enter a student's score *---------\ n ") on the keyboard;p rintf ("---------. Output all student information *---------\ n ");p rintf ("---------. Initialize Student information *---------\ n ");p rintf ("---------. Given the number, show a student's job Completion *---------\ n ");p rintf ("---------*6. Given a student's school number, modify the student's information *---------\ n "); Modify printf ("---------*7. Delete Student information *---------\ n ");p rintf ("---------*8. Given a class's class number, show that all students in that class have completed their homework *---------\ n ");p rintf ("---------*9.    Output the ranking of students in a class *---------\ n ");    printf ("---------*10. Output the ranking of all students ' assignments *---------\ n"); printf ("---------*******************************************************---------\ n");} int Choiceitem () {//select menu int Choice;d o{displaymenu ();p rintf ("Please select a function number you want to perform:"); scanf ("%d", &choice);} while (choice<0 | | choice >10); return choice;} void Init (Stutype *s) {s->length=0;}    void Inputainfo (stuinfo* as,stutype* s) {//Enter a student's score by typing printf ("Enter study number: \ n") via the keyboard; int j,num;scanf ("%d", &num), for (j=0;j<s->length;j++) {if (s->stu[j].num==num) {printf ("study number                already exists, please re-enter the study number: ");        scanf ("%d", &num), j=0; }} as->num=num;printf ("Input class: \ n"), scanf ("%d", &as->cls), As->name= (char*) malloc (;p rintf ("Enter name:"); scanf ("%s", as->name), int i;for (i = 0; i <; ++i) {printf ("Enter the student's score%d times: \ n", i+1); scanf ("%d", &as->score[i ]);}} int printaequ (stuType S,int Index) {//output a student's information inidex average int i,sum=0;for (i = 0; i <; ++i) {sum+=s.stu[index].score[i];} return (SUM/10);} void Printainfo (Stutype s,int index) {//output a student's information if (index!=-1) {int i,sum=0;printf ("%-11d%-6s%-6d", S.stu[index].num, S.STU[INDEX].NAME,S.STU[INDEX].CLS); for (i = 0; i <; ++i) {printf ("%-5d", S.stu[index].score[i]); sum+=s.stu[index ].score[i];} printf ("%4d\n", SUM/10);} elseprintf ("No this student!");}  void Inputallinfo (stutype *s, int length) {//Enter information for all students printf ("You are adding%d student information \ n", length); int i;for (i = 0; i < length; ++i) {if (S->length==max) {printf ("Out of limit! \ n "); Inputainfo (&s->stu[s->length],s); s->length++;}} void Printallinfo (Stutype s) {//Output all student information if (s.length==0) {printf ("No student information, please enter!")    \ n "); return;} printf ("Study number name");p rintf ("class"), int j;for (j=0;j<10;j++) {printf ("%dth", j+1);} printf ("Mean Score");p rintf ("\ n"), int i;for (i = 0; i < s.length; ++i) {printainfo (s,i);}} int search (Stutype s) {int num;printf ("input Study No.: \ n"), scanf ("%d", &numint i;for (i = 0; i < s.length; ++i) {if (s.stu[i].num==num) return i;} return-1;} void Modify (Stutype*s, Stutype stu) {//modify student information int num,scoreindex,fuckyou=0;if (s->length==0) printf ("No Student Information!\n"); else{printf ("Input study number:"); scanf ("%d", &num); int i,j;for (i = 0; I <= s->length;                ++i) {if (stu.stu[i].num==num) {printf ("Enter the number of results you want to modify:"), scanf ("%d", &scoreindex);p rintf ("The newly modified result is:"); scanf ("%d", &s->stu[i].score[scoreindex-1]); Fuckyou=1;}} if (! fuckyou) printf ("Without this student \ n");}} void del (stutype* s,int index) {//delete student information if (s->length==0)//Determine the length of the Stutype stu array stored by the student printf ("No This student!\n"); else {if (index!=-1)//When you call the search () function and return to index index for the student's small mark, the student is represented as S->stu[index] {for (; Dex < s->length;index++)//Data structure Tutorial P34 The idea of deleting data elements.                    To start with subscript index, the latter replaces the previous element.                s->stu[index]=s->stu[index+1];  s->length--;            Move forward. The entire array length is reduced by one, and the deletion data is implemented sequentially. }}}void Searchcls (stutype* s) {//Search by class inT cls,i;printf ("Input class: \ n"), scanf ("%d", &cls), if (!cls) printf ("No class \ n"); elsefor (i = 0; i < s->length; ++i) {if    (S-&GT;STU[I].CLS==CLS) Printainfo (*s,i);}} {//class internal score sort int Cls,i,k,scoreindex,passnum=0;int a[20];p rintf ("Input class: \ n"); Stuinfo ohshit;scanf ("%d", &cls); if (!        CLS)//printf ("Without this class \ n"); else{printf ("which job score or input 111 output average score:"); scanf ("%d", &scoreindex);p rintf ("name Study number"), scoreindex==111?printf ("Average \ n"):p rintf ("%d times \ n", scoreindex); int J=0;for (i = 0; i < s->length; ++i)//Traverse the stu of the entire storage student {if (S-&GT;STU[I].CLS==CLS)//Determine if the student's class CLS is the class to query {A[j]             =i; If the student is a student of this class, the student's subscript is saved to the array a[]j++;}}  j--; After traversing the array a[j] is stored in the query class of students s->stu[] subscript for (i=0;i<j;i++)//Data structure tutorial P293 bubble sort. Start {for (k=j;k>i;k--) {if (scoreindex==111)? Printaequ (*s,a[k]) > printaequ (*s,a[k-1]): S->stu[a[k]].sc ORE[SCOREINDEX-1] > S->stu[a[k-1]].score[scoreindex-1]) {OHshit=s->stu[a[k]];                        s->stu[a[k]]=s->stu[a[k-1]];                    s->stu[a[k-1]]=ohshit; }}}//Bubble sort end for (i=0;i<=j;i++) {if (s->stu[i].score[scoreindex-1]>=60 | | printaequ (*s,a[i]) >=            passnum++;p rintf ("%-10s", s->stu[a[i]].name);            printf ("%-14d", s->stu[a[i]].num); printf ("%-5d\n", (scoreindex==111) printaequ (*s,a[i]): S->stu[a[i]].score[scoreindex-1]);} printf ("The number of passes is%d, the total number is%d\n", passnum,j+1);}}    void Allinsort (Stutype *s) {int i,j,scoreindex,passnum=0;    printf ("Which job score is required or the input 111 output average score:"); scanf ("%d", &scoreindex);p rintf ("name Study number"), scoreindex==111?printf ("Average \ n"):p rintf ("%d times \ n", scoreindex); Stui NFO tmp;for (i=0;i<s->length-1;i++)//Data structure tutorial P293 bubble sort. Start {for (j=s->length-1;j>i;j--) {if (scoreindex==111)? printaequ (*s,j) > Printaequ (*s,j-1): S->stu[j].                         SCORE[SCOREINDEX-1] > S->stu[j-1].score[scoreindex-1]) {      tmp=s->stu[j];                                s->stu[j]=s->stu[j-1];                    s->stu[j-1]=tmp; }}//Bubble sort End}for (i=0;i<s->length;i++) {if (s->stu[i].score[scoreindex-1]>=60 | | printaequ (*s,i) >=60)    passnum++;            printf ("%-10s", s->stu[i].name);            printf ("%-14d", s->stu[i].num);    printf ("%-5d\n", (scoreindex==111) printaequ (*s,i): s->stu[i].score[scoreindex-1]); }printf ("Pass number:%d, total number:%d\n", passnum,s->length);} int main () {//main function Stutype student;student.length=0;int choice,index;init (&student); int Ch;do{choice=choiceitem () Switch (choice) {Case 1:printf ("Enter the number of student information you want to enter:"), scanf ("%d", &index); Inputallinfo (&student,index); break; Case 2:inputallinfo (&student,1); break;case 3:printallinfo (student); Break;case 4:init (&student); break;case 5:printainfo (Student,search (student)); Break;case 6:modify (&student, student); Break;case 7:del (&student, Search (student)); Break;casE 8:searchcls (&student); Break;case 9:clsinsort (&student); Break;case 10:allinsort (&student); break;}  System ("pause"); Press any key to continue running}while (choice); return 0;}

  

Student Management System

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.