Comprehensive evaluation system for students

Source: Internet
Author: User
Tags fread

#include <stdio.h>
#include <stdlib.h>
#define N 100

----------------------------------------function Declaration----------------------------------------
void Init ();
Char welcome ();
void Inputinfo ();
void view ();
void Xiugai ();
void Deleteinfo ();
void paiming1 (struct student_info student[]);
void Paiming2 (struct student_info student[]);
void Viewall ();
void Clean ();
void Paimingview ();
void exit ();
struct Student_info input ();
void Sortinfo (struct student_info student[]);
void ViewInfo (struct student_info *sp);
void Savestruct (struct student_info *sp,int size,int N,char filename[20]);
void Loadstruct (struct student_info *sp,int size,int N,char filename[20]);
void Saveint (int *p,int size,int N,char filename[20]);
void Loadint (int *p,int size,int N,char filename[20]);
int numexist (struct student_info student[],int num);

---------------------------------Define student information structure----------------------------------------

struct STUDENT_INFO
{
int num;//No.
Char name[6];//name
Char sex[5];//Sex
Char adress[20];//Home Address
Char tel[10];//Telephone
int chinese,math,english,huping,pingde,jiaoping,paiming1,paiming2;
Evaluation of Chinese Mathematics English for mutual evaluation of moral character
Double ave,zhongping;
Average synthesis

Each student's information is: study number, name, gender, home address, telephone number, language, mathematics, foreign language, the results of the single subjects,
Average test scores, exam rankings, peer-to-peer scoring, moral performance, classroom teacher rating, comprehensive assessment score, comprehensive assessment ranking.
The average scores of examinations, students ' mutual scores, moral results and teachers ' scores respectively accounted for the overall score of 60%,10%,10%,20%.
};

---------------------------------define the global structure body data----------------------------------------
struct Student_info student[n];
int counter,pm;

//----------------------------------------------main function----------------------------------------
Void main ()
{
Char select;
Init (); Call the initialization function
while (1)
{
Select=welcome ();
Switch (Select)
{
case ' 1 ': System ("CLS"), Inputinfo (); break;//Option 1: Enter student information
Case ' 2 ': System ("CLS"); view (); Break Option 2: Browse Student information
Case ' 3 ': System ("CLS"), Xiugai (); break;//Option 3: Modify student information
Case ' 4 ': System ("CLS");D Eleteinfo (); Option 4: Delete Student information
case ' 5 ': System ("CLS"); paiming1 (student);p aiming2 (student); Pm=1;getchar ();
GetChar (); System ("CLS"); break;//Option 5: Student Information ranking
case ' 6 ': System ("CLS"); Viewall (); break; Option 6: Browse all student Information
Case ' 7 ': System ("CLS"), Clean (), break;//option 7: Clear All information
Case ' 8 ': System ("CLS"); Paimingview (); break;//option 8: Query rank
case ' 0 ': System ("CLS"); exit (), break;//Option 9: Exit
}
}
}

----------------------------------------initialization function----------------------------------------
void Init ()
{
FILE *FP;
Fp=fopen ("Counter.dat", "RB");//Open the Count variable counter file

if (fp!=null)//load into counter
{
Fclose (FP);
Loadint (&counter,sizeof (counter), 1, "Counter.dat");
}
Else
{
Fp=fopen ("Counter.dat", "WB");//If there is no counter file, create one, counter is initially 0.
Fclose (FP);
counter=0;
}

if (counter!=0)//Load student data
Loadstruct (student,sizeof (struct student_info), counter, "Student_info.dat");
}

//----------------------------------------Welcome function----------------------------------------
Char welcome ()
{
Char Select;
while (1)
{
System ("CLS");
printf ("\t\t Welcome to use Student information management system \ n");
printf ("\ n");
printf ("1. Enter student information \ n");
printf ("2. viewing student information \ n");
printf ("3. Modify student information \ n");
printf ("4. Delete Student information \ n");
printf ("5. Ranking student results \ n");
printf ("6. View all student information \ n \ nthe");
printf ("7. Erase all data \ n \ nthe");
printf ("8. Query rank \ n");
printf ("0. exit \ n \ nthe");
printf ("Enter the corresponding function number:");
Select=getchar ();
if (select== ' 1 ' | | select== ' 2 ' | | select== ' 3 ' | | select== ' 4 ' | | select== ' 5 ' | | select== ' 6 ' | | select== ' 7 ' | | select== ' 8 ' | | select== ' 0 ')
return select;
System ("CLS");
Continue;
}
}

-------------------------------------1. Enter Student information----------------------------------------
void Inputinfo ()
{
int i,n;
printf ("Information on how many students need to be entered:");
scanf ("%d", &n);
System ("CLS");
for (i=1;i<=n;i++)
{
Student[counter]=input ();
counter++;
}
pm=0;
Sortinfo (student);
Savestruct (student,sizeof (struct student_info), counter, "Student_info.dat");
Saveint (&counter,sizeof (counter), 1, "Counter.dat");
}

-------------------------------------2. Explore Student Information----------------------------------------
void View ()
{
int i,num;
printf ("Please enter the number of student information to be visited:");
scanf ("%d", &num);
GetChar ();
if ((I=numexist (student,num)) ==-1)
{
printf ("The number does not exist, press ENTER to return ...");
GetChar ();
System ("CLS");
Return
}
ViewInfo (&student[i]);
printf ("\ n press ENTER to return ...");
GetChar ();
System ("CLS");
Return
}

-------------------------------------3. Modify Student Information----------------------------------------
void Xiugai ()
{
int i,num;
Char Yn,select;
printf ("Please enter the number of student information to be modified:");
scanf ("%d", &num);
GetChar ();
if ((I=numexist (student,num)) ==-1)
{
printf ("The number does not exist, press ENTER to return ...");
GetChar ();
System ("CLS");
Return
}
ViewInfo (&student[i]);
printf ("Do you want to modify? (y/n): ");
scanf ("%c", &yn);
GetChar ();
if (YN! = ' y ' && YN! = ' y ')
{
printf ("Modify Cancel.");
GetChar ();
System ("CLS");
Return
}
System ("CLS");
printf ("1. School number \ n");
printf ("2. sex \ n");
printf ("3. Home address \ n");
printf ("4. Contact phone \ n");
printf ("5. Language score \ n");
printf ("6. Math results \ n");
printf ("7. Foreign language score \ n");
printf ("8. Peer rating \ n");
printf ("9. Moral result \ n");
printf ("0. Instructor Teacher rating \ n");
scanf ("%c", &select);
Switch (SELECT)
{
Case ' 1 ':p rintf ("revision number:"); scanf ("%d", &student[i].num); break;
Case ' 2 ':p rintf ("Modified Gender:"); scanf ("%s", &student[i].sex); break;
Case ' 3 ':p rintf ("Modified Home Address:"); scanf ("%s", &student[i].adress); break;
Case ' 4 ':p rintf ("Modify Contact Number:"); scanf ("%s", &student[i].tel); break;
Case ' 5 ':p rintf ("Revised language score:"); scanf ("%d", &student[i].chinese); break;
Case ' 6 ':p rintf ("Revise Math score:"); scanf ("%d", &student[i].math); break;
Case ' 7 ':p rintf ("Modify foreign Language Score:"); scanf ("%d", &student[i].english); break;
Case ' 8 ':p rintf ("Revise classmates to score:"); scanf ("%d", &student[i].huping); break;
Case ' 9 ':p rintf ("revision of character score:"); scanf ("%d", &student[i].pingde); break;
Case ' 0 ':p rintf ("Modified Instructor Rating:"); scanf ("%d", &student[i].jiaoping); break;
}
Sortinfo (student);
Savestruct (student,sizeof (struct student_info), counter, "Student_info.dat");
pm=0;
GetChar ();
printf ("Modify complete ...");
GetChar ();
System ("CLS");
}

-------------------------------------4. Delete Student Information----------------------------------------
void Deleteinfo ()
{

int i,j,num;
Char YN;
printf ("Please enter the student informatics number to be deleted:");
scanf ("%d", &num);
GetChar ();
if ((I=numexist (student,num)) ==-1)
{
printf ("No such number, press ENTER return ...");
GetChar ();
System ("CLS");
Return
}

ViewInfo (&student[i]);
printf ("\ n confirm deletion (y/n):");
scanf ("%c", &yn);
GetChar ();
if (yn!= ' y ' && yn!= ' y ')
{
printf ("Remove Cancel ...");

}
Else
{
for (j=i;j<counter-1;j++)
STUDENT[J]=STUDENT[J+1];
counter--;
pm=0;
Savestruct (student,sizeof (struct student_info), counter, "Student_info.dat");
Saveint (&counter,sizeof (counter), counter, "Counter.dat");
printf ("Delete Complete ...");
}

GetChar ();
System ("CLS");
}

-------------------------------------average score and overall score------------------------------------
void paiming1 (struct student_info student[])
{
struct Student_info *p[n],*temp;
int i,j;
for (i=0;i<counter;i++)
p[i]=&student[i];
for (i=0;i<counter-1;i++)
for (j=i+1;j<counter;j++)
{
if (P[i]->ave < P[j]->ave)
{
Temp=p[i];
P[I]=P[J];
P[j]=temp;
}
}
for (i=0;i<counter;i++)
p[i]->paiming1=i+1;
printf ("Average sub-ranking completed ... \ n");

}

Ranking of comprehensive assessments
void Paiming2 (struct student_info student[])
{
struct Student_info *p[n],*temp;
int i,j;
for (i=0;i<counter;i++)
p[i]=&student[i];
for (i=0;i<counter-1;i++)
for (j=i+1;j<counter;j++)
{
if (P[i]->zhongping < p[j]->zhongping)
{
Temp=p[i];
P[I]=P[J];
P[j]=temp;
}
}
for (i=0;i<counter;i++)
p[i]->paiming2=i+1;
printf ("Comprehensive evaluation sub-ranking completed ... \ n");
}

----------------------------------6. View all student Information----------------------------------------
void Viewall ()
{
int i;
for (i=0;i<counter;i++)
{
ViewInfo (&student[i]);
printf ("\ n");
}
GetChar ();
printf ("Enter return ...");
GetChar ();
System ("CLS");
}

-------------------------------------7. Clear All information----------------------------------------
void Clean ()
{
counter=0;
Saveint (&counter,sizeof (counter), 1, "Counter.dat");
printf ("Purge complete ...");
GetChar ();
GetChar ();
System ("CLS");
}

----------------------------------------8. Query ranking----------------------------------------
void Paimingview ()
{
int i,num;
printf ("Enter the number to query:");
scanf ("%d", &num);
GetChar ();
I=numexist (Student,num);
if (i==-1)
{
printf ("The school number does not exist ...");
GetChar ();
Return
}
if (pm==0)
{
printf ("Please score first ...");
GetChar ();
Return
}
printf ("%s average score%d\n", student[i].name,student[i].paiming1);
printf ("%s's comprehensive evaluation score%d\n", student[i].name,student[i].paiming2);
printf ("Press ENTER to return ...");
GetChar ();
Return
}

----------------------------------------9. Exit----------------------------------------
void exit ()
{

printf ("Thank you for using!\n");
Exit (0);
}

----------------------------------------Input Information function----------------------------------------
struct Student_info input ()
{
struct Student_info stu,*sp;
Char YN;
sp=&stu;
while (1)
{
while (1)
{
printf ("Enter the school Number:");
scanf ("%d", &sp->num);
GetChar ();
if (Numexist (student,sp->num)!=-1)
{
printf ("The number already exists, please re-enter ...");
GetChar ();
System ("CLS");
Continue
}
Break
}
printf ("Enter name:");
Gets (Sp->name);
printf ("Input Gender:");
Gets (Sp->sex);
printf ("Input home Address:");
Gets (sp->adress);
printf ("Input Contact Number:");
Gets (Sp->tel);
printf ("\ n next entry result \ n");
printf ("Language:");
scanf ("%d", &sp->chinese);
printf ("Mathematics:");
scanf ("%d", &sp->math);
printf ("English:");
scanf ("%d", &sp->english);
Sp->ave= (Sp->chinese+sp->math+sp->english)/3.0;
printf ("Peer reviews:");
scanf ("%d", &sp->huping);
printf ("Moral Score:");
scanf ("%d", &sp->pingde);
printf ("Teacher Evaluation:");
scanf ("%d", &sp->jiaoping);
GetChar ();
Sp->zhongping= (sp->ave*0.6+sp->huping*0.1+sp->pingde*0.1+sp->jiaoping*0.2);
printf ("Input complete, confirm the information is correct (y/n)");
Yn=getchar ();
GetChar ();
if (yn== ' Y ' | | yn== ' y ')
Break
Else
{
printf ("Press ENTER to re-enter information.") ");
GetChar ();
System ("CLS");
Continue
}
}
System ("CLS");
return Stu;
}


----------------------------------------sort function----------------------------------------
void Sortinfo (struct student_info student[])
{
int i,j;
struct Student_info temp;
for (i=0;i<counter-1;i++)
for (j=i+1;j<=counter-1;j++)
{
if (student[i].num<student[j].num)
{
Temp=student[i];
STUDENT[I]=STUDENT[J];
Student[j]=temp;
}
}
}

----------------------------------------Show Student Information----------------------------------------
void ViewInfo (struct student_info *sp)
{
printf ("School number \ t name \ t sex \ t home address \ t Contact phone \ n");
printf ("%d\t%s\t%s\t%s\t\t%s\n", Sp->num,sp->name,sp->sex,sp->adress,sp->tel);
printf ("language \ t math \ t English \ t mutual evaluation \ t character \ t teaching evaluation \ n");
printf ("%d\t%d\t%d\t%d\t%d\t%d\t\n", sp->chinese,sp->math,sp->english,sp->huping,sp->pingde,sp- >jiaoping);
printf ("Average division \ t comprehensive sub \ n");
printf ("%.2f\t%.2f\n", sp->ave,sp->zhongping);
if (pm==1)
{
printf ("average rank \ t Comprehensive Assessment sub rank \ n");
printf ("%d\t\t%d\n", sp->paiming1,sp->paiming2);
}
}

-----------------------------------information to disk (structure)----------------------------------------
void Savestruct (struct student_info *sp,int size,int N,char filename[20])
{
FILE *FP;
Fp=fopen (filename, "WB");
Fwrite (SP,SIZE,N,FP);
Fclose (FP);
}

-----------------------------------read information (struct)----------------------------------------
void Loadstruct (struct student_info *sp,int size,int N,char filename[20])
{
FILE *FP;
Fp=fopen (filename, "RB");
Fread (SP,SIZE,N,FP);
Fclose (FP);


}

-------------------------------------information (integer)----------------------------------------
void Saveint (int *p,int size,int N,char filename[20])
{
FILE *FP;
Fp=fopen (filename, "WB");
Fwrite (P,SIZE,N,FP);
Fclose (FP);
}

-------------------------------------Read information (integral type)----------------------------------------
void Loadint (int *p,int size,int N,char filename[20])
{
FILE *FP;
Fp=fopen (filename, "RB");
Fread (P,SIZE,N,FP);
Fclose (FP);
}

----------------------------------------Search Number----------------------------------------
int numexist (struct student_info student[],int num)
{
int i;
for (i=0;i<counter;i++)
{
if (student[i].num==num)
return i;
}
return-1;
}

Comprehensive evaluation system for students

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.