C + + linked list to achieve student performance management system (simple version)

Source: Internet
Author: User

That year C language class to write this is not written out, now have time, wrote a simple, slightly to make up for the regret has been.

#include <iostream> using namespace std;
    typedef struct student{int id;//number string sex;
    String name;
int cpp;//c++ score struct student *next;


}stu;

Stu *head=null; void Test (); Whether the test head pointer is an empty void record ();//records result void modify ();//modify result void print ();//print single score void aver ();//ask for the average score of each section void Count ();
    ID Add ();//Add student void Delt ();//delete student void print ();//print score int main () {int choice;
    cout<< "\t\t\t Student Achievement Management System \n\n\n";
    cout<< "0. Exit System 1. Record Information 2. Modify information 3. Average score 4. Statistical Results 5. Add Information 6. Delete Information 7. Print results \ n";
    cout<< "Input selection (0-7):";
    cin>>choice;
            while (1) {switch (choice) {case 0:exit (0);   Case 1:record ();
            Break   Case 2:modify ();
            Break   Case 3:aver ();
            Break   Case 4:count ();
            Break   Case 5:add ();
            Break   Case 6:delt ();
            Break   Case 7:print ();
           Break   default:cout<< "input error!\n";
    Break    } cout<< "Input selection (0-7):";
    cin>>choice;
return 0;
    	} void Test () {if (!head) {cout << head null\n;
    Exit (-1);
    } void Record () {Stu *p,*q;
    int i,n;
    cout<< "Enter the number of students:";
    cin>>n;
    i=0;
    cout<< "Input Student Information: Name learning number sex score \ n";
        while (i<n) {p=new stu;
            if (head==null) {head=p;
        Q=head;
            else {cin>>p->name>>p->id>>p->sex>>p->cpp;
            q->next=p;
            Q=p;
        i++;
    }} void Modify () {cout<< "Enter the student's number to modify:";
    int id;
    cin>>id;
    Stu *p;
    Test ();
    p=head->next;
            while (p) {if (p->id==id) {cout<< "Please select the content you want to modify: \ n";
            cout<< "1.id 2.name 3.sex 4.cpp\n";
            int choice;
            cin>>choice; Switch (choice)
            {Case 1: {int newid;
                    cout<< "Enter the newly learned number:";
                    cin>>newid;
                    p->id=newid;
                Break
                    Case 2: {string newname;
                    cout<< "Enter new name:";
                    cin>>newname;
                    p->name=newname;
                Break
                    Case 3: {string newsex;
                    cout<< "Enter the new sex:";
                    cin>>newsex;
                    p->sex=newsex;
                Break
                    Case 4: {int newcpp;
                    cout<< "Enter the new score:";
                    cin>>newcpp;
                    p->cpp=newcpp;
                Break default:cout<< "entered incorrectly!\n ";
            Break
        } break;
    } p=p->next;
    } void Aver () {Stu *p;
    int sum,i;
    sum=0;
    i=0;
    Test ();
    p=head->next;
        while (p) {sum+=p->cpp;
        i++;
    p=p->next;


cout<< "All classmates C + + 's average score is:" <<sum/i<<endl;}
    void Count () {int max;
    Stu *p,*q;
    Test ();
    p=head->next;
    max=p->cpp;
    Q=p;
        while (1) {p=p->next;
        if (p==null) break;
            if (max<p->cpp) {max=p->cpp;
        Q=p;


cout<<q->name<< "C + + got the first name \ n" << "highest divided into:" <<max<<endl;}
    void Add () {Stu *p,*q;
    P=new Stu;
    cout<< "Enter the name of the new addition classmate gender C + + results:";
    cin>>p->name>>p->id>>p->sex>>p->cpp;
    p->next=head->next;
head->next=p;
    } void Delt () {//system ("CLS");
    Stu *p,*q;
    int id; Cout<< "Enter the student's school number to delete:";
    cin>>id;
    Test ();
    Q=head;
    p=q->next;
            while (1) {if (p->id==id) {q->next=p->next;
            Delete p;
        Break
        } q=p;
    p=q->next;
    } void Print () {Stu *p;
    Test ();
    p=head->next;
        while (p) {cout<<p->name<< "" <<p->cpp<<endl;
    p=p->next; }
}


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.