C + + Package list implementation--Student Information management Analysis system

Source: Internet
Author: User

class.h  header file #include <string> #include  <iostream> #include  <iomanip>             //implements SETW () wide-byte output using namespace  std;class studate{public:struct student{string name;//name string sex;//sex int id; float eng,math,chinese,c,sum;struct student *next;};}; class stulist :p ublic studate{private:int num;//number struct student *head;public: Stulist (); Void _creat (); Void _print (); Void _sort ();}; Stulist::stulist () {this->head=null;this->num=0;} Void stulist::_creat () {char res =  ' Y ';struct student *p1,*p2;p1=p2=new  Struct student;while (res== ' Y '  | |  res ==  ' Y ') {if (this->head == null) {this->head=p1;p1->id=0;} ELSE{P2-&GT;NEXT=P1;} cout<< "Name:";cin>>p1->name;cout<< "Sex:";cin>>p1->sex;cout<< "Chinese:"; cin >>p 1->chinese;cout<< "Math:";cin>>p1->math;cout<< "中文版:"; cin>>p1->eng;cout << "C language:"; cin>>p1->c;p1->id=this->num+1;p1->sum=p1->chinese+p1->math+p1->eng+ p1->c;this->num++;p 2=p1;p1=new struct student;cout<< "\ nthe continuation of input (y/n):"; Cin>>res;if ( res == ' N ' | |  res ==  ' n ') break;} P2->next=null;} Void stulist::_print () {struct student *temp;temp=this->head;cout<< "id" &LT;&LT;SETW (5) << "Name" &LT;&LT;SETW (5) << "Sex" <<setw << "Chinese" <<setw (5) << "Math" < &LT;SETW (8) << "中文版" &LT;&LT;SETW (5) << "C" &LT;&LT;SETW (5) << "Sum" <<endl;for (int i= 0;i<this->num;i++) {COUT&LT;&LT;TEMP-&GT;ID&LT;&LT;SETW (5) &LT;&LT;TEMP-&GT;NAME&LT;&LT;SETW (5) << TEMP-&GT;SEX&LT;&LT;SETW (5) &LT;&LT;TEMP-&GT;CHINESE&LT;&LT;SETW (5) &LT;&LT;TEMP-&GT;MATH&LT;&LT;SETW (5) << TEMP-&GT;ENG&LT;&LT;SETW (5) &LT;&LT;TEMP-&GT;C&LT;&LT;SETW (5) &LT;<temp->sum<<endl;temp=temp->next;} cout<<endl;cout<< "Total number of------------------------------------------------------------:" <<this- >num;cout<<endl;} Void stulist::_sort () {struct student *first;/* The header pointer of an orderly chain after arranging */struct student *tail;/* The end-of-order pointer */struct student *p_max;struct student *max;struct student *p;p=this-the ordered chain after arranging >head;if (this->head!=null) {first=null;while  (head != null) {for  (p=this->head,max= This->head; p->next!=null; p=p->next) {if  (p->next->sum > max-> SUM)//sorted by total score {p_max=p;max=p->next;}} if (first==null) {First=max;tail=max;} Else{tail->next=max;tail=max;} if (max==this->head) {this->head=this->head->next;} Else{p_max->next=max->next;}} if (first!=null) {tail->next=null;} cout<< "id" &LT;&LT;SETW (5) << "Name" &LT;&LT;SETW (5) << "Sex" &LT;&LT;SETW (Ten) << "Chinese" < &LT;SETW (5) << "Math" << SETW (8) << "中文版" &LT;&LT;SETW (5) << "C" &LT;&LT;SETW (5) << "Sum" <<endl;for (int i=0;i <this->num;i++) {COUT&LT;&LT;FIRST-&GT;ID&LT;&LT;SETW (5) &LT;&LT;FIRST-&GT;NAME&LT;&LT;SETW (5) << FIRST-&GT;SEX&LT;&LT;SETW (5) &LT;&LT;FIRST-&GT;CHINESE&LT;&LT;SETW (5) &LT;&LT;FIRST-&GT;MATH&LT;&LT;SETW (5) < &LT;FIRST-&GT;ENG&LT;&LT;SETW (5) &LT;&LT;FIRST-&GT;C&LT;&LT;SETW (5) <<first->sum<<endl;first= First->next;}}} stu.cpp     call class. h#include  "Class.h" Int main () {stulist a; A._creat (); A._print (); A._sort (); return 0;}


This article is from the "Creative Pilgrim" blog, so be sure to keep this source http://dearch.blog.51cto.com/10423918/1758724

C + + Package list implementation--Student Information management Analysis system

Related Article

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.