C + + Student performance Management system

Source: Internet
Author: User
Tags strcmp

Although compare water =. = But two lessons were written + one Noon is a pot of obsessive-compulsive disorder

Http://www.cnblogs.com/wenruo/p/4940182.html

#include <cstdio> #include <cstring> #include <iostream>using namespace Std;class student//Student    The class is a node of the management system {friend Class Studentmessage;    Student *next;    Char name[30];    Char num[30];        Double score[6];p ublic:student () {strcpy (name, "null");        strcpy (num, "null");    for (int i = 0; i < 6; ++i) score[i] = 0;        } Student (const student &a) {strcpy (name, a.name);        strcpy (num, a.num);    for (int i = 0; i < 6; ++i) score[i] = A.score[i];  } student &input () {cout << "name:";        CIN >> name;  cout << "Study No.:";        CIN >> Num;            for (int i = 0; i < 5; ++i) {cout << "enter" << (i + 1) << "Gate score:";            CIN >> Score[i];        SCORE[5] + = Score[i];    } return *this;    } student* Get_next () {return next; } void Print () {PRINTF ("%8s%10s", name, num);        for (int i = 0; i < 6; ++i) printf ("%6.2f", Score[i]);    printf ("\ n");        } void Swap ()//Swaps the current node and the next {char temp[30];        strcpy (temp, name);        strcpy (name, next->name);        strcpy (Next->name, temp);        strcpy (temp, num);        strcpy (num, next->num);        strcpy (Next->num, temp);            for (int i = 0; i < 6; ++i) {int tmp = Score[i];            Score[i] = next->score[i];        Next->score[i] = tmp;    }}};class studentmessage{protected:student *first;    Student *last;public:studentmessage () {first = last = new Student;        } ~studentmessage () {Clear ();    Delete first;           } studentmessage &append ();       Inserts a node student *find (const char *x) at the tail of the list;                       find void Query ();           Query Studentmessage &delete ();            Delete Find node Studentmessage &clear (); Delete allNode Studentmessage &sort ();                       sort void print () by Class I course;                         Show all nodes int menu ();    Display menu};studentmessage &studentmessage::append () {Student x;    X.input ();    Student *ptr = last;    *ptr = x;    last = new Student;    Ptr->next = Last; return *this;}    Studentmessage &studentmessage::D elete () {char x[30];    cout << "Enter the information to be deleted (school number or name) \ n";    CIN >> X;    Student *ptr = Find (x);        if (ptr = = last) {cout << "no relevant information found \ n";    return *this;    } ptr->print (); cout << "Do you want to delete this information?"    (is input 1, no input 0) ";    CIN >> X;            if (*x = = ' 1 ') {if (ptr = = first) {first = first->next;        Delete first;            } else {student *temp = first;            while (temp->next! = ptr) temp = temp->next;            Temp->next = ptr->next;        Delete ptr;    } cout << "deleted \ n";    } else{cout << "cancelled \ n"; } return *this;}    Studentmessage &studentmessage::clear () {char ch[30]; cout << "will delete all information.    Confirm, press Y ";    CIN >> ch;        if (*ch! = ' y ' && *ch! = ' y ') {cout << "cancelled \ n";    return *this;    } student *ptr = first;        while (ptr! = last) {Student *next = ptr->next;        Delete ptr;    ptr = next;    } first = last; return *this;}        void Studentmessage::p rint () {if (first = = last) {cout << "no information \ n";    return;    } cout << "---------------------------------score list------------------------------" << Endl;    cout << "Serial number 1 Results 2 results 3 results 4 results 5 Total" << Endl;    int no = 1;    Student *ptr = first;        while (ptr! = last) {printf ("%3d:", no++);        Ptr->print ();    PTR = ptr->next;    }}student *studentmessage::find (const char *x) {student *ptr = first; while (ptr! = last) {if (sTRCMP (ptr->name, x) = = 0 | |        strcmp (ptr->num, x) = = 0) break;    PTR = ptr->next; } return ptr;}    void Studentmessage::query () {char x[30];    cout << "Enter the information you want to inquire about (study number or name)";    CIN >> X;    Student *ptr = Find (x);    if (ptr = = last) {cout << "no query to relevant information \ n";    } else {ptr->print ();    }}//Bubble sort Studentmessage &studentmessage::sort () {int x; cout << "input which course do you want to follow?"    (1-5) Total input 6): ";    CIN >> X;    x--;    Student *ptr, *cnt = last;        while (cnt! = first) {ptr = first;                while (ptr->next! = cnt) {if (ptr->next->score[x] > Ptr->score[x]) {            Ptr->swap ();        } ptr = ptr->next;    } cnt = ptr; } return *this;}    int Studentmessage::menu () {cout << "===============================\n";    cout << "student performance management system \ n";    cout << "1. Show all student results \ n"; cout << "2. Add information \ n";    cout << "3. Enquiry information \ n";    cout << "4. Delete information \ n";    cout << "5. Order of achievement \ n";    cout << "6. Delete all information \ n";    cout << "0. exit \ n";    cout << "===============================\n";    int ch;    CIN >> ch; return ch;}    int main () {studentmessage ls;    int ch;            while (ch = ls.menu ()) {switch (ch) {case 1:ls.print (); Case 2:ls. Append ();            Break Case 3:ls. Query ();            Break Case 4:ls. Delete ();            Break Case 5:ls. Sort ();            Break Case 6:ls. Clear ();        Break }} return 0;}

  

C + + 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.