Student Performance Management System

Source: Internet
Author: User
Tags fread

Analytical:

Recently helped a friend to do a student performance management system equivalent to the curriculum design, they are required to write in C, for a child who is accustomed to C + + really feel the limitations of writing up to feel no language, not to say directly on the code

#include "student.h" void Main () {char ch= ' 0 '; int index=0;char id[id_size];student students;student phead; FILE *output=fopen ("Output.txt", "w+"); FILE *input=fopen ("Input.txt", "R"), if (input==null) {printf ("Open failed input\n"); exit (1);} if (input==null) {printf ("Open failed output\n"); exit (1);} Phead.next=null;initstudent (&students); while (1) {showlist ();p rintf ("Please select:"); Ch=getchar (); switch (CH) {case ' 1 ': Student_insert (&students); Break;case ' 2 ': Student_display (&students); Break;case ' 3 ': {printf (" Please enter how many students you need to find: "); scanf ("%d ", &index); Student_displaysingle (&students,index);} Break;case ' 4 ': {printf ("Please enter the number to be removed:"); scanf ("%s", id); Student_delete (&students,id);} Break;case ' 5 ': student_modify (&students); Break;case ' 6 ': {printf ("Please enter the student's name:"); scanf ("%s", id); Student_select (&students,id);} Break;case ' 7 ': Student_sortbyaverage (&students,&phead); Break;case ' 8 ': {io_readinfo (&students,output) ; fclose (output);} Break;case ' 9 ': {io_writeinfo (&students,output); fclose (output);} Break;case ' 0 ': {PRINTF ("Welcome to Student Management Performance system \ n"); exit (1);} Default:break;} GetChar ();}}


#include <stdio.h> #include <stdlib.h> #include <math.h> #include <assert.h> #include <  string.h> #define Id_size 128#define name_size 128#define SIZE 125struct Student{char id[id_size]; Student number Char name[name_size];   Student name float Math; math float 中文版;  English float Chinese; Chinese float totalscore; Total score: float Averagescore;  Average divided int passstudent; Pass number struct student *next;};   typedef struct Student student;static float passrate=0.0; Pass Rate//Initialize student information void initstudent (student *head) {strcpy (Head->id, ""); strcpy (Head->name, ""); head->chinese= 0.0;head->english=0.0;head->math=0.0;head->passstudent=0;head->totalscore=0;head->next=null;} Insert student results void Student_insert (Student *head) {int flag=0;student *cur=head;student *tmp= (Student *) malloc (sizeof ( Student) Tmp->next=null;assert (TMP!=null);p rintf ("* * * Start inputting Student Information ***\n");p rintf ("Please enter the study number:"); scanf ("%s",tmp-> ID);p rintf ("Please enter Name:"), scanf ("%s", Tmp->name);p rintf ("Enter Math score:"), scanf ("%f", &tmp->math);p rintf ("pleaseInput English score: "); scanf ("%f ", &tmp->english);p rintf (" Please input language score: "); scanf ("%f ", &tmp->chinese);tmp-> Totalscore=tmp->chinese+tmp->english+tmp->math;tmp->averagescore=tmp->totalscore/3;tmp-> Passstudent=0;if (Tmp->chinese >=60) tmp->passstudent++;if (tmp->english >=60) tmp->PassStudent++; if (Tmp->math >=60) tmp->passstudent++;if (tmp->passstudent==3) flag++;tmp->averagescore=tmp-> totalscore/3;printf ("Student Pass Number:%d\n", flag); while (Cur->next!=null) cur=cur->next;cur->next=tmp;} /* Delete Student information */void student_delete (Student *head,char *id) {Student *del=null;student *cur=head;while (Cur->next!=NULL) {if (strcmp (cur->next->id,id) ==0) {Del=cur->next;cur->next=del->next;free (del);p rintf ("delete succeeded \ n"); return;} Cur=cur->next;} printf ("Delete failed \ n");} /* Modify student Information */void student_modify (Student *head) {char number[id_size];int flag=0;student *cur=head->next;assert (cur!) =null);p rintf ("Enter student Number:"), scanf ("%s", numbers);p rintf ("Start looking up \ n"), while (cur!=null) {if (StRCMP (Cur->id,number) ==0) {printf ("Please enter the language score to be modified:"), scanf ("%f", &cur->chinese);p rintf ("Please enter the math score for Modification:"); scanf ("%f", &cur->math);p rintf ("Please enter the English score prepared for revision:"); scanf ("%f", &cur->english); flag=1;break;} Cur->next;} if (flag) printf ("Modification succeeded \ n"); elseprintf ("Modification failed \ n");} /* Query by name */void student_select (Student *head,char *name) {Student *cur=head->next;while (cur!=null) {if (strcmp (cur- >name,name) (==0) {printf ("existence of this student \ \"); return;} Cur=cur->next;} printf ("Find failed by name \ n");} /* Displays a single student record */void Student_displaysingle (Student *head,int index) {int count=1;student *cur=head->next;while (count <index && cur!=null) {cur=cur->next;count++;} if (count >index) printf ("No this student \ n"); else{printf ("%s\t%s\t%.3f\t%.3f\t%.3f\t",cur->id,cur->name,cur-> Chinese,cur->math,cur->english);p rintf ("%.3f\t%.3f\n", Cur->averagescore,cur->totalscore);}} Show all student grades void Student_display (Student *head) {int count=0;int number=0;student *cur=head->next;printf ("number \ t \ name \ T language \ n math \ t english \ t average points \ t total "); while(cur!=null) {printf ("%s\t%s\t%.3f\t%.3f\t%.3f\t", cur->id,cur->name,cur->chinese,cur->math,cur->english); printf ("%.3f\t%.3f\n", Cur->averagescore,cur->totalscore); if (Cur->chinese >=60 && cur-> english>=60 && cur->math>=60) count++;cur=cur->next;number++;} Passrate= (float) count/number*100;printf ("Pass rate:%.1f%%\n", passrate);} /* Sort by average */void student_sortbyaverage (Student *head,student *phead) {Student *pcur=null;student *tmp=null;student * Ptmp=null;student *cur=head->next;while (cur!=null) {pcur=cur;while (pcur!=null && pcur->averagescore = =int_max) pcur=pcur->next;if (pcur==null) break;tmp=pcur;while (pcur!=null) {if (Pcur->averagescore > tmp- >averagescore && Pcur->averagescore!=int_max) {tmp=pcur;} Pcur=pcur->next;} if (Tmp->averagescore!=int_max) {ptmp= (student *) malloc (sizeof (student)); assert (Ptmp!=null); strcpy (Ptmp->id , tmp->id); strcpy (ptmp->name,tmp->name);p tmp->chinese=tmp->chinese;ptmp->english=tmp->english;ptmp->math=tmp->math;ptmp->averagescore=tmp->averagescore;ptmp- >passstudent=tmp->passstudent;ptmp->totalscore=tmp->totalscore;ptmp->next=phead->next;phead- >next=ptmp;tmp->averagescore=int_max;}} Student_display (Phead);} /* Read the student information from the file */void io_readinfo (student *head,file *path) {student *cur=head->next;while (cur!=null) {if (fread, sizeof (student), 1,path) < 0) {printf ("fread failed\n"); Cur=cur->next;} printf ("read in success \ n");} /* Write student information to file */void io_writeinfo (student *head,file *path) {student *cur=head->next;while (cur!=null) {fprintf (path, "%s%s%f%f%f%f%f%d%s", Cur->id,cur->name,cur->math,cur->english,cur->chinese,cur->totalscore, Cur->averagescore,cur->passstudent, "\ n"); cur=cur->next;} printf ("Write data successfully \ n");}   Display list void Showlist () {printf ("**********************************************\n");p rintf ("* *" 1 "Insert student Score" 2 "displays all student information **\n ");p rintf (" * * "3" Display individual student "4" Delete student information **\n ");p rintf (" * * "5" Modify studentsInformation "6" by name Query **\n ");p rintf (" * * "7" Sort by average "8" read out student information from a file **\n ");p rintf (" * * "9" Write file "0" Exit Student management System **\n ");p rintf (" * * * * \ n ");}


Student Performance 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.