zoukankan      html  css  js  c++  java
  • 全班成绩变态算法

    #include<iostream>
    #include<string>
    using namespace std;
    typedef struct node
    {
    	string stunum,stuname;
    	int math,english,computer;
    	int averagescore;
    	node *next;
    }*ptrn;                                                     //结点
    class linklist
    {
    private:
    	int mathaverage,enaverage,coaverage;
    	ptrn mathtop,entop,cotop;
    	ptrn mathmin,enmin,comin;
        ptrn ms6,ms6_9,ms7_9,ms8_9,ms9;                     //各分数段头结点
        ptrn es6,es6_9,es7_9,es8_9,es9;
        ptrn cs6,cs6_9,cs7_9,cs8_9,cs9;
    	ptrn head;
    	
    public:
        void creatlist()                                  //创建链表
    	{
    		head=0;
    	   ptrn temp,newnode;
    	   int n;
    	   while(1)
    	   {
    		   cout<<"0表示终止输入,1表示继续"<<endl;
    		   
    		   cin>>n;
    		   if(n==0)
    			   break;
    		   else
    		   {
                    cout<<"请按照学号,姓名,数学,英语,计算机的顺序输入,"<<endl;
    		        newnode=new node;
    		        cin>>newnode->stunum>>newnode->stuname>>newnode->math>>newnode->english>>newnode->computer;
    		        if(head==0)
    				{
    					head=newnode;
    					temp=newnode;
    				}
    				else
    				{
    					temp->next=newnode;
    					temp=newnode;
    				}
    		   }
    		  
    	   }
    	   if(head)temp->next=0;
    	}
    
    	int length(ptrn &e)                                                 //求链长度
    	{
    		int count=0;
    		ptrn temm;
    		temm=e;
    		while(1)
    		{
    			if(temm==0)
    			{
    				break;
    			}
    			else
    			{
    				count++;
    				temm=temm->next;
    			}
    		}
    		return count;
    	}
    	void averagescorerank()                                           //平均分排名
    	{	
    
    		for(int i=0;i<length(head);i++)
    		{
    			ptrn temm;
    		    temm=head;
                for(int j=0;j<length(head)-i-1;j++)
    			{
    				if(temm->averagescore<temm->next->averagescore)        //交换顺序
    				{
    					string tem,temp;
    				   int temath,temen,temco,temaverage;
    				   tem=temm->next->stunum;
    				   temp=temm->next->stuname;
    				   temath=temm->next->math;
    				   temen=temm->next->english;
    				   temco=temm->next->computer;
    				   temaverage=temm->next->averagescore;
    				   temm->next->stunum=temm->stunum;
    				   temm->next->stuname=temm->stuname;
    				   temm->next->math=temm->math;
    				   temm->next->english=temm->english;
    				   temm->next->computer=temm->computer;
    				   temm->next->averagescore=temm->averagescore;
    				   temm->stunum=tem;
    				   temm->stuname=temp;
    				   temm->math=temath;
    				   temm->english=temen;
    				   temm->computer=temco;
    				   temm->averagescore=temaverage;
    				}
    				temm=temm->next; 			
    			}
    		}
    		cout<<"      "<<"按照平均成绩排名由高到低为"<<endl;
            ptrn tem;
            tem=head;
    		while(1)
    		{
    		   if(tem!=0)
    		   {
    			   cout<<"      "<<tem->stunum<<"  "<<tem->stuname<<"  "<<tem->averagescore<<endl;
    			   tem=tem->next;
    		   }
    		   else
    			   break;
    		}
    	}
    	void mathrank()                                       //数学排名
    	{
            
    		for(int i=0;i<length(head);i++)
    		{
    			 ptrn temm;
    		     temm=head;
                for(int j=0;j<length(head)-i-1;j++)
    			{
                   if(temm->math<temm->next->math)
    				{
    					
    					string tem,temp;
    				   int temath,temen,temco,temaverage;
    				   tem=temm->next->stunum;
    				   temp=temm->next->stuname;
    				   temath=temm->next->math;
    				   temen=temm->next->english;
    				   temco=temm->next->computer;
    				   temaverage=temm->next->averagescore;
    				   temm->next->stunum=temm->stunum;
    				   temm->next->stuname=temm->stuname;
    				   temm->next->math=temm->math;
    				   temm->next->english=temm->english;
    				   temm->next->computer=temm->computer;
    				   temm->next->averagescore=temm->averagescore;
    				   temm->stunum=tem;
    				   temm->stuname=temp;
    				   temm->math=temath;
    				   temm->english=temen;
    				   temm->computer=temco;
    				   temm->averagescore=temaverage;
    				
    
    				}
    				temm=temm->next;
    			}
    		}
    		mathtop=new node;
    		mathtop->stunum=head->stunum;
    		mathtop->stuname=head->stuname;
    		mathtop->math=head->math;
    		mathtop->english=head->english;
    		mathtop->computer=head->computer;
    		mathtop->averagescore=head->averagescore;
    		cout<<"      "<<"按照数学成绩排名由高到低为"<<endl;
            ptrn tem;
            tem=head;
    		mathaverage=0;
    		while(1)
    		{
    		   if(tem!=0)
    		   {
    			   cout<<"      "<<tem->stunum<<"  "<<tem->stuname<<"  "<<tem->math<<endl;
    			   mathaverage+=tem->math;
    			   if(tem->next==0)
    			   {
    				   mathmin=tem;
    			   }
    			   tem=tem->next;   
    		   }
    		   else
    			   break;
    		}                                                   
    		
    	}
    	void enlishrank()                                              //英语排名
    	{
    	   	for(int i=0;i<length(head);i++)
    		{
    			 ptrn temm;
    		     temm=head;                              
                for(int j=0;j<length(head)-i-1;j++)
    			{
                   if(temm->english<temm->next->english)
    				{
    					 	
    					string tem,temp;
    				   int temath,temen,temco,temaverage;
    				   tem=temm->next->stunum;
    				   temp=temm->next->stuname;
    				   temath=temm->next->math;
    				   temen=temm->next->english;
    				   temco=temm->next->computer;
    				   temaverage=temm->next->averagescore;
    				   temm->next->stunum=temm->stunum;
    				   temm->next->stuname=temm->stuname;
    				   temm->next->math=temm->math;
    				   temm->next->english=temm->english;
    				   temm->next->computer=temm->computer;
    				   temm->next->averagescore=temm->averagescore;
    				   temm->stunum=tem;
    				   temm->stuname=temp;
    				   temm->math=temath;
    				   temm->english=temen;
    				   temm->computer=temco;
    				   temm->averagescore=temaverage;
    				}
    				temm=temm->next;
    			}
    		}
    	   	entop=new node;
    	    entop->stunum=head->stunum;
    		entop->stuname=head->stuname;
    		entop->math=head->math;
    		entop->english=head->english;
    		entop->computer=head->computer;
    		entop->averagescore=head->averagescore;                              
    		cout<<"      "<<"按照英语成绩排名由高到低为"<<endl;
            ptrn tem;
            tem=head;
    		enaverage=0;
    		while(1)
    		{
    		   if(tem!=0)
    		   {
    			   cout<<"      "<<tem->stunum<<"  "<<tem->stuname<<"  "<<tem->english<<endl;
    			   enaverage+=tem->english;
    			   if(tem->next==0)
    			   {
    				   enmin=tem;
    			   }
    			   tem=tem->next;   
    		   }
    		   else
    			   break;
    		}
    	}
    	void computerrank()                                                  //计算机排名
    	{
    		for(int i=0;i<length(head);i++)
    		{
    			 ptrn temm;
    		     temm=head;
                for(int j=0;j<length(head)-i-1;j++)
    			{
                   if(temm->computer<temm->next->computer)
    				{
    					string tem,temp;
    				   int temath,temen,temco,temaverage;
    				   tem=temm->next->stunum;
    				   temp=temm->next->stuname;
    				   temath=temm->next->math;
    				   temen=temm->next->english;
    				   temco=temm->next->computer;
    				   temaverage=temm->next->averagescore;
    				   temm->next->stunum=temm->stunum;
    				   temm->next->stuname=temm->stuname;
    				   temm->next->math=temm->math;
    				   temm->next->english=temm->english;
    				   temm->next->computer=temm->computer;
    				   temm->next->averagescore=temm->averagescore;
    				   temm->stunum=tem;
    				   temm->stuname=temp;
    				   temm->math=temath;
    				   temm->english=temen;
    				   temm->computer=temco;
    				   temm->averagescore=temaverage;
    				}
    				temm=temm->next;
    			}
    		}
    	    cotop=new node;
    		cotop->stunum=head->stunum;
    		cotop->stuname=head->stuname;
    		cotop->math=head->math;
    		cotop->english=head->english;
    		cotop->computer=head->computer;
    		cotop->averagescore=head->averagescore;
    		cout<<"      "<<"按照计算机成绩排名由高到低为"<<endl;
            ptrn tem;
            tem=head;
    		coaverage=0;
    		while(1)
    		{
    		   if(tem!=0)
    		   {
    			   cout<<"      "<<tem->stunum<<"  "<<tem->stuname<<"  "<<tem->computer<<endl;
    			   coaverage+=tem->computer;
    			   if(tem->next==0)
    			   {
    				   comin=tem;
    			   }
    			 tem=tem->next;  
    		   }
    		   else
    			   break;
    		}
    	}
        void mathsection()                                                //数学分数段
    	{
    		 
    		 ptrn tem,temmath60,temmath69,temmath79,temmath89,temmath90;
    		 ms6=0;ms6_9=0;ms7_9=0;ms8_9=0;ms9=0;
    		 tem=head;
    		 ptrn newnode;
    		 while(1)
    		 {
    			 if(tem!=0)
    			 {  
    				  newnode=new node;
                         newnode->stunum=tem->stunum;
    				     newnode->stuname=tem->stuname;
    				     newnode->averagescore=tem->averagescore;
    			         newnode->math=tem->math;
    				     newnode->english=tem->english;
    				     newnode->computer =tem->computer ;
    				 if(tem->math<60)
    				 {
    					 if(ms6==0)
    					 {
    						 ms6=newnode;
    						 temmath60=newnode;
    					 }		
    					 else	
    					 {
    						 temmath60->next=newnode;
    						 temmath60=newnode;
    					 }
    				 }
    		    	else if(tem->math>=60&&tem->math<=69)
    				{
    				   if(ms6_9==0)
    				   {
    					   
    			    	 ms6_9=newnode;
    					 temmath69=newnode; 
    				   }
    				   else
    				   {
    				      temmath69->next=newnode;
    					  temmath69=newnode; 
    				   }
    				}
    			    else if(tem->math>=70&&tem->math<=79)
    				{
    				    if(ms7_9==0)
    					{
    					  ms7_9=newnode;
    					  temmath79=newnode;
    					}
    				    else
    					{
    					   temmath79->next=newnode;
    				       temmath79=newnode;
    					}
    				}
    			    else if(tem->math>=80&&tem->math<=89)
    				{
    					 
    				   if(ms8_9==0)
    				   {
    					 ms8_9=newnode;
    					 temmath89=newnode;
    				   }
    			       else
    				   {
    					 temmath89->next=newnode; 
    					 temmath89=newnode;
    				   }
    				}
    			    else
    				{
    					
    				   if(ms9==0)
    				   {
    					 ms9=newnode;
    					 temmath90=newnode;
    				   }
    				   else
    				   {
    					 temmath90->next=newnode;
    					 temmath90=newnode;
    				   }
    				}
    			   tem=tem->next;
    			 }
    		     else
    			 { 
    				  break; 
    			 } 
    		 }
    		  
    		 if(ms6)temmath60->next=0;
    		 if(ms6_9)temmath69->next=0;
    		 if(ms7_9)temmath79->next=0;
    		 if(ms8_9)temmath89->next=0;
    		 if(ms9)temmath90->next=0;
    	    
    	}
    	  void ensection()                                             //英语分段
    	{
    		 
    		 ptrn tem,temen60,temen69,temen79,temen89,temen90;
    		 es6=0;es6_9=0;es7_9=0;es8_9=0;es9=0;
    		 tem=head;
    		  ptrn newnode;
    		 while(1)
    		 {
    			 if(tem!=0)
    			 {  
    				  newnode=new node;
                         newnode->stunum=tem->stunum;
    				     newnode->stuname=tem->stuname;
    				     newnode->averagescore=tem->averagescore;
    			         newnode->math=tem->math;
    				     newnode->english=tem->english;
    				     newnode->computer =tem->computer ;
    				 if(tem->english<60)
    				 {
    					 if(es6==0)
    					 {
    						 es6=newnode;
    						 temen60=newnode;
    					 }		
    					 else	
    					 {
    						 temen60->next=newnode;
    						 temen60=newnode;
    					 }
    				 }
    		    	else if(tem->english>=60&&tem->english<=69)
    				{
    				   if(es6_9==0)
    				   {
    					   
    			    	 es6_9=newnode;
    					 temen69=newnode; 
    				   }
    				   else
    				   {
    				      temen69->next=newnode;
    					  temen69=newnode; 
    				   }
    				}
    			    else if(tem->english>=70&&tem->english<=79)
    				{
    				    if(es7_9==0)
    					{
    					  es7_9=newnode;
    					  temen79=newnode;
    					}
    				    else
    					{
    					   temen79->next=newnode;
    				       temen79=newnode;
    					}
    				}
    			    else if(tem->english>=80&&tem->english<=89)
    				{
    					 
    				   if(es8_9==0)
    				   {
    					 es8_9=newnode;
    					 temen89=newnode;
    				   }
    			       else
    				   {
    					 temen89->next=newnode; 
    					 temen89=newnode;
    				   }
    				}
    			    else
    				{
    					
    				   if(es9==0)
    				   {
    					 es9=newnode;
    					 temen90=newnode;
    				   }
    				   else
    				   {
    					 temen90->next=newnode;
    					 temen90=newnode;
    				   }
    				}
    			   tem=tem->next;
    			 }
    		     else
    			 { 
    				  break; 
    			 } 
    		 }
    		  
    		 if(es6)temen60->next=0;
    		 if(es6_9)temen69->next=0;
    		 if(es7_9)temen79->next=0;
    		 if(es8_9)temen89->next=0;
    		 if(es9)temen90->next=0;
    	    
    	}
    	 void cosection()                                           //计算机分段
    	{
    		 
    		 ptrn tem,temco60,temco69,temco79,temco89,temco90;
    		 cs6=0;cs6_9=0;cs7_9=0;cs8_9=0;cs9=0;
    		 tem=head;
    		  ptrn newnode;
    		 while(1)
    		 {
    			 if(tem!=0)
    			 {  
    				  newnode=new node;
                         newnode->stunum=tem->stunum;
    				     newnode->stuname=tem->stuname;
    				     newnode->averagescore=tem->averagescore;
    			         newnode->math=tem->math;
    				     newnode->english=tem->english;
    				     newnode->computer =tem->computer ;
    				 if(tem->computer<60)
    				 {
    					 if(cs6==0)
    					 {
    						 cs6=newnode;
    						 temco60=newnode;
    					 }		
    					 else	
    					 {
    						 temco60->next=newnode;
    						 temco60=newnode;
    					 }
    				 }
    		    	else if(tem->computer>=60&&tem->computer<=69)
    				{
    				   if(cs6_9==0)
    				   {
    					   
    			    	 cs6_9=newnode;
    					 temco69=newnode; 
    				   }
    				   else
    				   {
    				      temco69->next=newnode;
    					  temco69=newnode; 
    				   }
    				}
    			    else if(tem->computer>=70&&tem->computer<=79)
    				{
    				    if(cs7_9==0)
    					{
    					  cs7_9=newnode;
    					  temco79=newnode;
    					}
    				    else
    					{
    					   temco79->next=newnode;
    				       temco79=newnode;
    					}
    				}
    			    else if(tem->computer>=80&&tem->computer<=89)
    				{
    					 
    				   if(cs8_9==0)
    				   {
    					 cs8_9=newnode;
    					 temco89=newnode;
    				   }
    			       else
    				   {
    					 temco89->next=newnode; 
    					 temco89=newnode;
    				   }
    				}
    			    else
    				{
    					
    				   if(cs9==0)
    				   {
    					 cs9=newnode;
    					 temco90=newnode;
    				   }
    				   else
    				   {
    					 temco90->next=newnode;
    					 temco90=newnode;
    				   }
    				}
    			   tem=tem->next;
    			 }
    		     else
    			 { 
    				  break; 
    			 } 
    		 }
    		  
    		 if(cs6)temco60->next=0;
    		 if(cs6_9)temco69->next=0;
    		 if(cs7_9)temco79->next=0;
    		 if(cs8_9)temco89->next=0;
    		 if(cs9)temco90->next=0;
    	    
    	}
    	void outputmathsection()                                        //输出数学分段部分
    	{
    		 cout<<"      "<<"数学成绩不及格情况如下"<<endl;
    		 cout<<"      "<<"人数为"<<"         "<<length(ms6)<<endl;
    		 cout<<"      "<<"学号"<<"    "<<"姓名"<<"    "<<"数学成绩"<<endl;
    		  ptrn tempp1;
    		 tempp1=ms6;
    		 while(1)
    		 {
    			 if(tempp1!=0)
    			 {
    				 cout<<"      "<<tempp1->stunum<<"          "<<tempp1->stuname<<"            "<<tempp1->math<<endl;
    				 tempp1=tempp1->next; 
    			 }
    			 else
    				 break;
    		 }
    		 cout<<"      "<<"数学成绩60-69情况如下"<<endl;
    		 cout<<"      "<<"人数为"<<"         "<<length(ms6_9)<<endl;
    		 cout<<"      "<<"学号"<<"       "<<"姓名"<<"       "<<"数学成绩"<<endl;
    		 ptrn tempp2;
    		 tempp2=ms6_9;
    		 while(1)
    		 {
    			 if(tempp2!=0)
    			 {
    				 cout<<"      "<<tempp2->stunum<<"           "<<tempp2->stuname<<"            "<<tempp2->math<<endl;
    				 cout<<endl;
    				 cout<<endl;
    				 tempp2=tempp2->next;
    			 }
    			 else
    				 break;
    		 }
             cout<<"      "<<"数学成绩70-79情况如下"<<endl;
    		 cout<<"      "<<"人数为"<<"               "<<length(ms7_9)<<endl;
    		 cout<<"      "<<"学号"<<"       "<<"姓名"<<"       "<<"数学成绩"<<endl;
    	     ptrn tempp3;
    		 tempp3=ms7_9;
    		 while(1)
    		 {
    			 
    			 if(tempp3!=0)
    			 {  
    				 cout<<"      "<<tempp3->stunum<<"           "<<tempp3->stuname<<"            "<<tempp3->math<<endl;
    				 cout<<endl;
    				 cout<<endl;
    				 tempp3=tempp3->next;
    			 }
    			 else
    				 break;
    		 }
    		  cout<<"      "<<"数学成绩80-89情况如下"<<endl;
    		 cout<<"      "<<"人数为"<<"                 "<<length(ms8_9)<<endl;
    		 cout<<"      "<<"学号"<<"       "<<"姓名"<<"       "<<"数学成绩"<<endl;
    		 ptrn tempp4;
    		 tempp4=ms8_9;
    		 while(1)
    		 {
    			 if(tempp4!=0)
    			 { 
    				 cout<<"      "<<tempp4->stunum<<"          "<<tempp4->stuname<<"             "<<tempp4->math<<endl;
    				 cout<<endl;
    				 cout<<endl;
    				 tempp4=tempp4->next;
    			 }
    			 else
    				 break;
    		 }
    		  cout<<"      "<<"数学成绩90以上情况如下"<<endl;
    		 cout<<"      "<<"人数为"<<"                "<<length(ms9)<<endl;
    		 cout<<"      "<<"学号"<<"        "<<"姓名"<<"        "<<"数学成绩"<<endl;
    		 ptrn tempp5;
    		 tempp5=ms9;
    		 while(1)
    		 {
    			 if(tempp5!=0)
    			 {
    				 cout<<"      "<<tempp5->stunum<<"         "<<tempp5->stuname<<"            "<<tempp5->math<<endl;
    				 cout<<endl;
    				 cout<<endl;
    				 tempp5=tempp5->next;
    			 }
    			 else
    				 break;
    		 }
    	}
    	void outputensection()                                                //输出英语分段部分
    	{
            cout<<"      "<<"英语成绩不及格情况如下"<<endl;
    		 cout<<"      "<<"人数为"<<"             "<<length(es6)<<endl;
    		 cout<<"      "<<"学号"<<"       "<<"姓名"<<"       "<<"英语成绩"<<endl;
    		  ptrn tempp1;
    		 tempp1=es6;
    		 while(1)
    		 { 
    			 if(tempp1!=0)
    			 {
    				 cout<<"      "<<tempp1->stunum<<"          "<<tempp1->stuname<<"           "<<tempp1->english<<endl;
    				 cout<<endl;
    				 cout<<endl;
    				 tempp1=tempp1->next;
    			 }
    			 else
    				 break;
    		 }
    		  cout<<"      "<<"英语成绩60-69情况如下"<<endl;
    		 cout<<"      "<<"人数为"<<"                  "<<length(es6_9)<<endl;
    		 cout<<"      "<<"学号"<<"       "<<"姓名"<<"       "<<"英语成绩"<<endl;
    		 ptrn tempp2;
    		 tempp2=es6_9;
    		 while(1)
    		 {
    			 if(tempp2!=0)
    			 {
    				 cout<<"      "<<tempp2->stunum<<"         "<<tempp2->stuname<<"          "<<tempp2->english<<endl;
    				 cout<<endl;
    				 cout<<endl;
    				 tempp2=tempp2->next;
    			 }
    			 else
    				 break;
    		 }
             cout<<"      "<<"英语成绩70-79情况如下"<<endl;
    		 cout<<"      "<<"人数为"<<"               "<<length(es7_9)<<endl;
    		 cout<<"      "<<"学号"<<"      "<<"姓名"<<"      "<<"英语成绩"<<endl;
    		 ptrn tempp3;
    		 tempp3=es7_9;
    		 while(1)
    		 {
    			 if(tempp3!=0)
    			 {
    				 cout<<"      "<<tempp3->stunum<<"         "<<tempp3->stuname<<"           "<<tempp3->english<<endl;
    				 cout<<endl;
    				 cout<<endl;
    				 tempp3=tempp3->next;
    			 }
    			 else
    				 break;
    		 }
    		  cout<<"      "<<"英语成绩80-89情况如下"<<endl;
    		 cout<<"      "<<"人数为"<<"                  "<<length(es8_9)<<endl;
    		 cout<<"      "<<"学号"<<"      "<<"姓名"<<"      "<<"英语成绩"<<endl;
    		 ptrn tempp4;
    		 tempp4=es8_9;
    		 while(1)
    		 {
    			 
    			 if(tempp4!=0)
    			 {
    				 cout<<"      "<<tempp4->stunum<<"         "<<tempp4->stuname<<"           "<<tempp4->english<<endl;
    				 cout<<endl;
    				 cout<<endl;
    				 tempp4=tempp4->next;
    			 }
    			 else
    				 break;
    		 }
    		  cout<<"      "<<"英语成绩90以上情况如下"<<endl;
    		 cout<<"      "<<"人数为"<<"                 "<<length(es9)<<endl;
    		 cout<<"      "<<"学号"<<"       "<<"姓名"<<"       "<<"英语成绩"<<endl;
    		 ptrn tempp5;
    		 tempp5=es9;
    		 while(1)
    		 {
    			
    			 if(tempp5!=0)
    			 {  
    				 cout<<"      "<<tempp5->stunum<<"         "<<tempp5->stuname<<"            "<<tempp5->english<<endl;
    				 cout<<endl;
    				 cout<<endl;
    				 tempp5=tempp5->next;
    			 }
    			 else
    				 break;
    		 }
    	}
    	void outputcosection()                                         //输出计算机分段部分
    	{
    		 cout<<"      "<<"计算机成绩不及格情况如下"<<endl;
    		 cout<<"      "<<"人数为"<<"                "<<length(cs6)<<endl;
    		 cout<<"      "<<"学号"<<"       "<<"姓名"<<"       "<<"计算机成绩"<<endl;
    		 ptrn tempp1;
    		 tempp1=cs6;
    		 while(1)
    		 {
    			 if(tempp1!=0)
    			 {
    				 cout<<"      "<<tempp1->stunum<<"         "<<tempp1->stuname<<"            "<<tempp1->computer<<endl;
    				 cout<<endl;
    				 cout<<endl;
    				 tempp1=tempp1->next;
    			 }
    			 else
    				 break;
    		 }
    		  cout<<"      "<<"计算机成绩60-69情况如下"<<endl;
    		 cout<<"      "<<"人数为"<<"                 "<<length(cs6_9)<<endl;
    		 cout<<"      "<<"学号"<<"       "<<"姓名"<<"       "<<"计算机成绩"<<endl;
    		 ptrn tempp2;
    		 tempp2=cs6_9;
    		 while(1)
    		 {
    			
    			 if(tempp2!=0)
    			 {
    				 cout<<"      "<<tempp2->stunum<<"          "<<tempp2->stuname<<"            "<<tempp2->computer<<endl;
    				 cout<<endl;
    				 cout<<endl;
    				 tempp2=tempp2->next;
    			 }
    			 else
    				 break;
    		 }
             cout<<"      "<<"计算机成绩70-79情况如下"<<endl;
    		 cout<<"      "<<"人数为"<<"                    "<<length(cs7_9)<<endl;
    		 cout<<"      "<<"学号"<<"       "<<"姓名"<<"       "<<"计算机成绩"<<endl;
    		 ptrn tempp3;
    		 tempp3=cs7_9;
    		 while(1)
    		 {
    			
    			 if(tempp3!=0)
    			 {
    				 cout<<"       "<<tempp3->stunum<<"          "<<tempp3->stuname<<"            "<<tempp3->computer<<endl;
    				 cout<<endl;
    				 cout<<endl;
    				 tempp3=tempp3->next;
    			 }
    			 else
    				 break;
    		 }
    		  cout<<"      "<<"计算机成绩80-89情况如下"<<endl;
    		 cout<<"      "<<"人数为"<<"                 "<<length(cs8_9)<<endl;
    		 cout<<"      "<<"学号"<<"       "<<"姓名"<<"       "<<"计算机成绩"<<endl;
    		 ptrn tempp4;
    		 tempp4=cs8_9;
    		 while(1)
    		 {
    			 
    			 if(tempp4!=0)
    			 {
    				 cout<<"       "<<tempp4->stunum<<"         "<<tempp4->stuname<<"             "<<tempp4->computer<<endl;
    				 cout<<endl;
    				 cout<<endl;
    				 tempp4=tempp4->next;
    			 }
    			 else
    				 break;
    		 }
    		  cout<<"       "<<"计算机成绩90以上情况如下"<<endl;
    		 cout<<"       "<<"人数为"<<"                "<<length(cs9)<<endl;
    		 cout<<"       "<<"学号"<<"       "<<"姓名"<<"       "<<"计算机成绩"<<endl;
    		 ptrn tempp5;
    		 tempp5=cs9;
    		 while(1)
    		 {
    			 
    			 if(tempp5!=0)
    			 {
    				 cout<<"      "<<tempp5->stunum<<"         "<<tempp5->stuname<<"             "<<tempp5->computer<<endl;
    				 cout<<endl;
    				 cout<<endl;
    				 tempp5=tempp5->next;
    			 }
    			 else
    				 break;
    		 }
    	}
    	void serch()                                                       //查找
    	{
    		cout<<"********************(1)学号查询**************************"<<endl;
    		cout<<"********************(2)姓名查询**************************"<<endl;
    		cout<<"***************请输入提示的数字*********************"<<endl;
    		int m;
    		cin>>m;
    		if(m==1)
    		{
    			cout<<"******************请输入学号**************************"<<endl;
    			char *ch1;
    			ch1=new char[2];
    			cin>>ch1;
    			ptrn temn;
    			temn=head;
    			while(1)
    			{
    				if(temn!=0&&temn->stunum==ch1)
    				{
    					cout<<"***************所查学生的信息如下************************"<<endl;
    					cout<<"学号"<<"      "<<"姓名"<<"      "<<"数学"<<"      "<<"英语"<<"      "<<"计算机"<<endl;
    					cout<<temn->stunum<<"        "<<temn->stuname<<"        "<<temn->math<<"        "<<temn->english<<"       "<<temn->computer<<endl;break;
    				}
    				else if(temn!=0)
    				{
    					  temn=temn->next; 
    				}
    				else
    				{
    					break;
    				}
    			  
    			}
    		}
    		else
    		{
    			cout<<"******************请输入姓名**************************"<<endl;
    			char *ch2;
    			ch2=new char[10];
                cin>>ch2;
                ptrn temn;
    			temn=head;
    			while(1)
    			{
    				if(temn!=0&&temn->stuname==ch2)
    				{
    					cout<<"***************所查学生的信息如下************************"<<endl;
    					cout<<"学号"<<"    "<<"姓名"<<"    "<<"数学"<<"    "<<"英语"<<"    "<<"计算机"<<endl;
    					cout<<temn->stunum<<"       "<<temn->stuname<<"       "<<temn->math<<"       "<<temn->english<<"       "<<temn->computer<<endl;
    					break;
    				}
    				else if(temn!=0)
    				{
    					temn=temn->next;	 
    				}
    				else
    				{
    					break;
    				}
    			
    			}
    		}
    	}
    	 void output()                                                           //输出最高最低分
    	 {
    		 cout<<"数学平均分"<<"    "<<"英语平均分"<<"    "<<"计算机平均分"<<endl;
    		 cout<<mathaverage/length(head)<<"              "<<enaverage/length(head)<<"                    "<<coaverage/length(head)<<endl;
    		 cout<<"数学最高分"<<"    "<<"英语最高分"<<"    "<<"计算机最高分"<<endl;
    		 cout<<"   "<<mathtop->math<<"            "<<entop->english<<"           "<<cotop->computer<<endl;
    		 cout<<endl;
    		 cout<<"数学最低分"<<"    "<<"英语最低分"<<"    "<<"计算机最低分"<<endl;
    		 cout<<"    "<<mathmin->math<<"          "<<enmin->english<<"          "<<comin->computer<<endl;
    	 }
    };
    void main()
    {
    	linklist list;
    	list.creatlist();
    	list.averagescorerank();
    	list.mathrank();
    	list.enlishrank();
    	list.computerrank();
    	list.mathsection();
    	list.ensection();
    	list.cosection();
    	list.outputmathsection();
    	list.outputensection();
    	list.outputcosection();
    	list.output();
    	list.serch();
    }
    

  • 相关阅读:
    arm架构与体系结构
    C语言双链表遍历,插入,删除
    C语言实现单链表的遍历,逆序,插入,删除
    C语言函数的变参实用与分析
    DEBUG宏
    运算中的临时匿名变量
    main函数的传参与返回
    存储类、作用域、生命周期、链接属性
    制作动态链接库并使用
    内存管理——进程创建,执行,缺页,终止
  • 原文地址:https://www.cnblogs.com/zztong/p/6695293.html
Copyright © 2011-2022 走看看