完善的学生成绩计算统计

 //完善的学生成绩计算统计;kkkpo
//注意多留一个存储单元 i=0开始
#include<iostream.h>
#include<string.h>
const int N=100;
const int M=14;
const int P=30;
void array_in(int n,int m,float score[][M],char num[][P],char name[][P]);
void dzhongcj(int n,int m,float score[][M],char num[][P],char name[][P]);//每个学生的总成绩shuchu
void fencheng(int n,int m,float score[][M],char num[][P],char name[][P]);//成绩分层
void zaverage(int n,int m,float score[][M],char num[][P],char name[][P]);//总平均值
void average(int n,int m,float score[][M],char num[][P],char name[][P]);//每科平均成绩
void dankepx(int n,int m,float score[][M],char num[][P],char name[][P]);//单科排序
void zhongzjpx(int n,int m,float score[][M],char num[][P],char name[][P]);//总成绩排序
void taverage(int n,int m,float score[][M],char num[][P],char name[][P]);//单个同学平均成绩
void caizao(int n,int m,float score[][M],char num[][P],char name[][P]);//同学成绩查找;
void dankez(int n,int m,float score[][M],char num[][P],char name[][P]);//单科最优成绩
void zongz(int n,int m,float score[][M],char num[][P],char name[][P]);//总成绩最优成绩
void yxhxs(int n,int m,float score[][M],char num[][P],char name[][P]);//以学号形式查找信息
void yxhxs(int n,float x[],char num[][P],char name[][P]);
void yxmxs(int n,int m,float score[][M],char num[][P],char name[][P]);//以名字形式查找
void axmdx(int n,int m,float score[][M],char num[][P],char name[][P]);//按姓名大小排序
void axmdx(int n,float x[],char num[][P],char name[][P]);
void yxmxs(int n,float x[],char str[],char num[][P],char name[][P]);
float max(float [],int n);
float mix(float [],int n);
float average(float [],int n);
void  fenceng(float [],int n,char num[][P],char name[][P]);
void  lcp(float x[],int n,char num[][P],char name[][P],char str[]);
void  caizao(float x[],int n,char num[][P],char name[][P]);
void  mian(void);
void  miin(void)
{
 int n,m,k;
 char str[N];
    float score[N][M];
 char num[N][P];
 char name[N][P];
 char x='y';
 cin.get();
 cout<<endl;
 cout<<"要进行成绩处理输入任意键否则N或n";
    cin>>x;
 while(x!='N'&&x!='n')
 {
   cout<<"班级:";
   cin>>str;
   cout<<"参考人数n=";
   cin>>n;
   cout<<"科目 m=";
      cin>>m;
   array_in(n,m,score,num,name);
   cin.get();
      while(x!='N'&&x!='n')
      {
    cout<<"每个学生的总成绩(1) 成绩评优(2) 总平均成绩值(3)"<<endl;
       cout<<"单科平均成绩    (4) 单科排序(5)  总成绩排序 (6)"<<endl;
       cout<<"同学平均成绩    (7) 同学成绩查找(8) 单科最优成绩(9)"<<endl;
    cout<<"总成绩最优成绩 (10) 按姓名大小排序(11)(总体情况咨询)"<<endl;
       cout<<"请选择k(1—14)=";
       cin>>k;//注意;着两个的区别
        //k=cin.get();//
       switch(k)
    {
        case 1: dzhongcj( n,m,score,num,name);
      break;
        case 2: fencheng(n,m,score,num,name);
      break;
        case 3: zaverage(n,m,score,num,name);
      break;
        case 4: average(n,m,score,num,name);
      break;
        case 5: dankepx(n,m,score,num,name);
      break;
        case 6: zhongzjpx(n,m,score,num,name);
      break;
        case 7: taverage(n,m,score,num,name);
      break;
        case 8: caizao(n,m,score,num,name);
      break;
        case 9: dankez(n,m,score,num,name);
      break;
        case 10: zongz(n,m,score,num,name);
      break;
     case 11: axmdx(n,m,score,num,name);
      break;
    }
   cout<<endl;
      cout<<"要继续进行该班成绩处理输入任意键否则N或n";
      cin>>x;
   cout<<endl;
   }
   cout<<endl;
      cout<<"要继续进行另一班成绩处理输入任意键否则N或n";
      cin>>x;
 }
}
void array_in(int n,int m,float score[][M],char num[][P],char name[][P])
{
      int i,j;
   for(i=0;i<n;i++)
   {
    cout<<"学号 ";
    cin>>num[i];
    cout<<"姓名 ";
    cin>>name[i];
    for(j=0;j<m;j++)
    {
     cout<<"分数"<<j+1<<"=";
     cin>>score[i][j];
    }
   }
}
void dzhongcj(int n,int m,float score[][M],char num[][P],char name[][P])//每个学生的总成绩
{
 int i,j;
 float sum=0;
 cout<<endl;
 cout<<" <<每个学生的总成绩>> "<<endl;
 cout<<endl;
 for(i=0;i<n;i++)
 {  
  sum=0;//赋初值为0;
  cout<<"学号 "<<num[i]<<" 姓名 "<<name[i]<<" 分数  ";
  for(j=0;j<m;j++)
  {  
   {
    cout<<score[i][j]<<" ";
       sum+=score[i][j];  
   }
  } 
  cout<<"总分:"<<sum<<endl;
 }
 cout<<endl;
}
void fencheng(int n,int m,float score[][M],char num[][P],char name[][P])//成绩分层
{
    int i,j,k,B;
 double b;
 char x='y';
 float sum=0;
 cout<<endl;
 cout<<" <<成绩评优>> "<<endl;
 cout<<endl;
 while(x!='N'&&x!='n')
    {
 cout<<endl;
 cout<<"总成绩分层(1) 单科分成(2)";
 cin>>k;
 cout<<endl;
 switch(k)
 {
 case 1:
  {
      for(i=0;i<n;i++)
   {
          sum=0;
     for(j=0;j<m;j++) 
        sum+=score[i][j]; 
        score[i][m]=sum;
   }
     for(i=0;i<n;i++)
     {
      sum=score[i][m];
      if(m>1)
      {   b=sum/100.0;
                      if(b<=m&&b>=(0.9*m))
             cout<<"学号 "<<num[i]<<" 姓名 "<<name[i]<<" "<<" 非常优秀!"<<endl;
          else if(b>=(0.8*m)&&b<(0.9*m))
                      cout<<"学号 "<<num[i]<<" 姓名 "<<name[i]<<" "<<" 良好!"<<endl;
          else if(b<(0.8*m)&&b>=(0.6*m))
             cout<<"学号 "<<num[i]<<" 姓名 "<<name[i]<<" "<<" 及格!"<<endl;
          else
             cout<<"学号 "<<num[i]<<" 姓名 "<<name[i]<<" "<<" 不及格!"<<endl;
      }
        if(m==1)
     {
         B=int(sum/10);
        switch(B)
     {
     case 10:
              case  9: cout<<"学号"<<num[i]<<" 姓名 "<<name[i]<<" 非常优秀!"<<endl;
                    break;
              case  8:
              case  7: cout<<"学号"<<num[i]<<" 姓名 "<<name[i]<<" 优良!"<<endl;
                    break;
                 case  6: cout<<"学号"<<num[i]<<" 姓名 "<<name[i]<<" 及格!"<<endl;
                    break;
              case  5:
              case  4:
              case  3:
              case  2:
              case  1:
              case  0: cout<<"学号"<<num[i]<<" 姓名 "<<name[i]<<" 不及格!"<<endl;
                    break;
     }
     }
     }
     cout<<endl;
  }
  break;
 case 2:
  {
   while(x!='N'&&x!='n')
   { 
    cout<<endl;
    cout<<"请输入科目j的j=";
          cin>>j;
    cout<<endl;
         for(i=0;i<n;i++)
      {
       B=int(score[i][j-1]/10);//注意;[j-1]
       switch(B)
    {
     case 10:
              case  9: cout<<"学号"<<num[i]<<" 姓名 "<<name[i]<<" 非常优秀!"<<endl;
                    break;
              case  8:
              case  7: cout<<"学号"<<num[i]<<" 姓名 "<<name[i]<<" 优良!"<<endl;
                    break;
                 case  6: cout<<"学号"<<num[i]<<" 姓名 "<<name[i]<<" 及格!"<<endl;
                    break;
              case  5:
              case  4:
              case  3:
              case  2:
              case  1:
              case  0: cout<<"学号"<<num[i]<<" 姓名 "<<name[i]<<"不及格!"<<endl;
                    break;
    }
      }
      cout<<endl;
      cout<<"要继续进行单科成绩评优输入任意键否则N或n";
      cin>>x;
      cout<<endl;
  }
  break;
  }
 }
 cout<<endl;
    cout<<"要继续进行成绩评优输入任意键否则N或n";
 cin>>x;
 }
 cout<<endl;
}
void zaverage(int n,int m,float score[][M],char num[][P],char name[][P])//总平均值
{   
 int i;
 int j;
 float sun=0;
 float sum;
 float sco[1000];
  cout<<endl;
        cout<<"<<总平均成绩值>>"<<endl;
  cout<<endl;
  for(i=0;i<n;i++)
  {
   sum=0;
   for(j=0;j<m;j++)
   {
    sum+=score[i][j];
   }
   sco[i]=sum;
  }
  for(i=0;i<n;i++)
  {
   sun+=sco[i];
   cout<<"学号 "<<num[i]<<" 姓名 "<<name[i]<<" "<<" 总分数 "<<sco[i]<<" "<<endl;  
  }
            cout<<"总平均成绩 "<<sun/n<<endl;//注意;复职方式
   cout<<endl;
}       
void average(int n,int m,float score[][M],char num[][P],char name[][P])//每科平均成绩
{
  
   int i,j;
   float sum=0;
   char x='y';
   cout<<endl;
   cout<<"<<每科平均成绩>>"<<endl;
   cout<<endl;
   while(x!='N'&&x!='n')
   {  
    cout<<endl;
    cout<<"请输入科目j的j=";
       cin>>j;
      for(i=0;i<n;i++)
   {
    cout<<"学号 "<<num[i]<<" 姓名 "<<name[i]<<" "<<" 分数 "<<score[i][j-1]<<endl;
    sum+=score[i][j-1];//注意[j-1];
   }
       cout<<"该单科平均成绩:"<<sum/n<<endl;
    cout<<endl;
    cout<<"要继续进行单科平均值输入任意键否则N或n";
    cin>>x;
   }
   cout<<endl;
}
void dankepx(int n,int m,float score[][M],char num[][P],char name[][P])//单科排序
{
 int i,j,k;
 char x='y';
 float sco;
 char nu[P];
 char na[P];
 float sum=0;
   cout<<endl;
   cout<<"<<单科成绩排序>>"<<endl;
   cout<<endl;
   while(x!='N'&&x!='n')
   {
     cout<<"输入单科代号j=";
     cin>>j;
     for(i=0;i<n;i++)
  {   
    sum+=score[i][j-1];
       for(k=i+1;k<n;k++)
    {   
         if(score[i][j-1]<score[k][j-1])
   {
     sco=score[i][j-1];//注意这里是j-1;
        score[i][j-1]=score[k][j-1];
     score[k][j-1]=sco;
     strcpy(na,name[i]);
     strcpy(name[i],name[k]);
     strcpy(name[k],na);
     strcpy(nu,num[i]);
     strcpy(num[i],num[k]);
     strcpy(num[k],nu);
   }
    }
  }
  for(i=0;i<n;i++)
  cout<<"学号 "<<num[i]<<" 姓名 "<<name[i]<<" 分数 "<<score[i][j-1]<<endl;
     score[n][j-1]=sum/n;
  cout<<"这科平均分 "<<score[n][j-1]<<endl;
  cout<<endl;
        cout<<"要继续单科排序输入任意键否则N或n";
     cin>>x;
   }
   cout<<endl;
}
void zhongzjpx(int n,int m,float score[][M],char num[][P],char name[][P])//总成绩排序
{
 int i,j,k;
 float sum;
 float max;
    char nu[P];
 char na[P];
 float sco;//注意;成绩是单个的 所以sco不要定义为数组
   if(n==1)
    for(j=0;j<m;j++)
    cout<<"学号"<<num[0]<<" 姓名 "<<name[0]<<" "<<" "<<score[1][j]<<" "<<score[0][m]<<endl;
   if(n==2)
   {
    if(score[0][m]<score[1][m])
    {
     for(j=0;j<m;j++)
        cout<<"学号"<<num[1]<<" 姓名 "<<name[1]<<" "<<"总分 "<<score[1][j]<<" "<<score[1][m]<<endl;
     cout<<endl;
           for(j=0;j<m;j++)
     cout<<"学号"<<num[0]<<" 姓名 "<<name[0]<<" "<<"总分 "<<score[0][j]<<" "<<score[0][m]<<endl;
     cout<<endl;
    }
       else
    {
     cout<<"学号"<<num[0]<<" 姓名 "<<name[0]<<" ";
     for(j=0;j<m;j++)
           {
    cout<<score[0][j]<<" ";
     }
     cout<<"总分 "<<score[0][m]<<endl;
           cout<<"学号"<<num[1]<<" 姓名 "<<name[1]<<" "<<" ";
           for(j=0;j<m;j++)
     {
      cout<<score[1][j]<<" ";
     }
     cout<<"总分 "<<score[1][m]<<endl;
   }
   }
   else
   {
    for(i=0;i<n;i++)
   {
          sum=0;//每次副初值为0;
     for(j=0;j<m;j++) 
        sum+=score[i][j]; 
        score[i][m]=sum;
   }
      for(i=0;i<n-1;i++)   
      for(k=i+1;k<n;k++)
   {
     if(score[i][m]<score[k][m])
     {
      max=score[i][m];
   score[i][m]=score[k][m];
            score[k][m]=max;
   strcpy(na,name[i]);//na=name[i+1];/////////////字符串的复制
   strcpy(name[i],name[k]);//name[i+1]=name[i+2];
   strcpy(name[k],na);//name[i+2]=na;
   strcpy(nu,num[i]);//nu=num[i+1];
   strcpy(num[i],num[k]);//num[i+1]=num[i+2];
   strcpy(num[k],nu);//num[i+2]=num[i+1];
            for(j=0;j<m;j++)
            {
    sco=score[i][j];
    score[i][j]=score[k][j];
    score[k][j]=sco;
   }
      /*if(score[i+1][m]>score[i][m])
   {
    max=score[i][m];
             score[i][m]=score[i+1][m];
    score[i+1][m]=max;
    strcpy(na,name[i]);//na=name[i];
    strcpy(name[i],name[i+1]);//name[i]=name[i+1];
    strcpy(name[i+1],na);//name[i+1]=na;
    strcpy(nu,num[i]);//nu=num[i];
    strcpy(num[i],num[i+1]);//num[i]=num[i+1];
    strcpy(num[i+1],nu);//num[i+1]=nu;
    for(j=0;j<m;j++)
    {
     sco=score[i][j];
     score[i][j]=score[i+1][j];
     score[i+1][j]=sco;
    }
   }*/
     }
   }
     for(i=0;i<n;i++)
  {
   cout<<"学号"<<num[i]<<" 姓名 "<<name[i]<<" 分数 ";
      for(j=0;j<m;j++)
   {
   cout<<" "<<score[i][j];
   }
   cout<<" 总分 "<<score[i][m]<<endl; 
  }
   }
}
void taverage(int n,int m,float score[][M],char num[][P],char name[][P])//单个同学平均成绩
{  
 int i,j;
 float sum;
 cout<<endl;
 cout<<"<<同学平均成绩>>"<<endl;
    cout<<endl;
      for(i=0;i<n;i++)
   {
        sum=0;//每次副初值为0;
     for(j=0;j<m;j++) 
      sum+=score[i][j]; 
      score[i][m]=sum;
   }
 for(i=0;i<n;i++)
 {
  cout<<"学号"<<num[i]<<" 姓名 "<<name[i]<<" 分数 ";
     for(j=0;j<m;j++)
  cout<<score[i][j]<<" ";
     cout<<" 平均分 "<<(score[i][m]/m)<<endl;
 }
 cout<<endl;
}
void caizao(int n,int m,float score[][M],char num[][P],char name[][P])//同学成绩查找;
{
    int k;
 char p='y';
 cout<<endl;
 cout<<"<<同学信息查找>>"<<endl;
 cout<<endl;
 while(p!='N'&&p!='n')
 {
  cout<<endl;
        cout<<"以学号形式输入(1)或以姓名形式输入(2)";
     cin>>k;
    switch(k)
    {
     case 1: yxhxs(n,m,score,num,name);
      break;
     case 2: yxmxs(n,m,score,num,name);
      break;
    }
    cout<<endl;
       cout<<"要继续进行同学信息查找输入任意键否则N或n";
    cin>>p;
   }
 cout<<endl;
}
void dankez(int n,int m,float score[][M],char num[][P],char name[][P])//单科最优成绩
{
  int i,j;
  int k;
  char nu[P];
  char na[P];
  float sco;
  char x='y';
  cout<<endl;
  cout<<"<<某一单科最优成绩>>"<<endl;
  cout<<endl;
 while(x!='N'&&x!='n')
 {
  cout<<endl;
  cout<<"输入单科代号j=";
     cin>>j;
     for(i=0;i<n;i++)
  {
   for(k=i+1;k<n;k++)
    {   
         if(score[i][j-1]<score[k][j-1])
   {
     sco=score[i][j-1];//注意这里是j-1;
        score[i][j-1]=score[k][j-1];
     score[k][j-1]=sco;
     strcpy(na,name[i]);
     strcpy(name[i],name[k]);
     strcpy(name[k],na);
     strcpy(nu,num[i]);
     strcpy(num[i],num[k]);
     strcpy(num[k],nu);
   }
    }
  }
   cout<<endl;
      cout<<"学号 "<<num[0]<<" 姓名 "<<name[0]<<" 最优分数"<<j<<" "<<score[0][j-1]<<endl;
   cout<<endl;
   cout<<"要继续单科最优成绩查找输入任意键否则N或n";
   cin>>x;
 }
 cout<<endl;
}
void zongz(int n,int m,float score[][M],char num[][P],char name[][P])//总成绩最优成绩
{
 int i;
 int j;
 int k;
 float sum;
 char nu[P];
 char na[P];
 float sco;
 cout<<endl;
 cout<<"<<总成绩最优成绩>>"<<endl;
 cout<<endl;
    for(i=0;i<n;i++)
   {
          sum=0;//每次副初值为0;
     for(j=0;j<m;j++) 
        sum+=score[i][j]; 
        score[i][m]=sum;
   }
    for(i=0;i<n;i++)
       for(k=i+1;k<n;k++)
    {   
         if(score[i][m]<score[k][m])
   {
     sco=score[i][m];//注意这里是j-1;
        score[i][m]=score[k][m];
     score[k][m]=sco;
     strcpy(na,name[i]);
     strcpy(name[i],name[k]);
     strcpy(name[k],na);
     strcpy(nu,num[i]);
     strcpy(num[i],num[k]);
     strcpy(num[k],nu);
   }
    }
     cout<<endl;
     cout<<"学号 "<<num[0]<<" 姓名 "<<name[0]<<" 最优总分数 "<<score[0][m]<<endl;
  cout<<endl;
}
void yxhxs(int n,int m,float score[][M],char num[][P],char name[][P])//以学号形式查找信息
{
 char nu[P];
 int i,j;
 float b;
 float sum;
 float sun;
 char x='y';
 cout<<endl;
 for(i=0;i<n;i++)
   {
          sun=0;
     for(j=0;j<m;j++) 
        sun+=score[i][j]; 
        score[i][m]=sun;
   }
 while(x!='N'&&x!='n')
 {
  cout<<endl;
  cout<<"请输入学号  ";
     cin>>nu;
     for(i=0;i<n;i++)
  {
     if(strcmp(num[i],nu)==0)//用来判断两个字符串相等
     {
             cout<<"学号 "<<num[i]<<" 姓名 "<<name[i]<<" 分数 ";
             for(j=0;j<m;j++)
             cout<<score[i][j]<<" ";
       cout<<"总分 "<<score[i][m]<<" ";//补充成绩分层
          sum=score[i][m];
          b=float(sum/100.0);
                      if(b<=m&&b>=(0.9*m))
             cout<<" 非常优秀!"<<endl;
          else if(b>=(0.8*m)&&b<(0.9*m))
                      cout<<" 良好!"<<endl;
          else if(b<(0.8*m)&&b>=(0.6*m))
             cout<<" 及格!"<<endl;
          else
             cout<<" 不及格!"<<endl;
     }
  }
  cout<<endl;
  cout<<"要继续进行学号形式查找学生信息按任意键否则输入N或n";
  cin>>x;
 }
 cout<<endl;
}
void axmdx(int n,int m,float score[][M],char num[][P],char name[][P])//按姓名大小排序
{
 int i,j,k;
 float sun,b,sum;
 char nu[P];
 char na[P];
 float sco;
  for(i=0;i<n;i++)
   {
          sun=0;
     for(j=0;j<m;j++) 
        sun+=score[i][j]; 
        score[i][m]=sun;
   }
  if(n==1)
  {
         cout<<"学号 "<<num[0]<<" 姓名 "<<name[0]<<" ";
   for(j=0;j<m;j++)
    cout<<score[0][j]<<" ";
       cout<<" 总分 "<<score[0][m]<<" ";
             sum=score[0][m];
       b=float(sum/100.0);
                      if(b<=m&&b>=(0.9*m))
             cout<<" 非常优秀!"<<endl;
          else if(b>=(0.8*m)&&b<(0.9*m))
                      cout<<" 良好!"<<endl;
          else if(b<(0.8*m)&&b>=(0.6*m))
             cout<<" 及格!"<<endl;
          else
             cout<<" 不及格!"<<endl;
  }
  else
  {
   for(i=0;i<n-1;i++)
   for(k=i+1;k<n;k++)
   {
    if(strcmp(name[i],name[k])>0)
    {
                  strcpy(na,name[i]);
            strcpy(name[i],name[k]);
            strcpy(name[k],na);
            strcpy(nu,num[i]);
            strcpy(num[i],num[k]);
            strcpy(num[k],nu);
      sco=score[i][m];//注意这里是j-1;
               score[i][m]=score[k][m];
            score[k][m]=sco;
       for(j=0;j<m;j++)
       {
      sco=score[i][j];
      score[i][j]=score[k][j];
      score[k][j]=sco;
       }
    }
   }
   for(i=0;i<n;i++)
   {
    cout<<"学号 "<<num[i]<<" 姓名 "<<name[i]<<" 分数 ";
             for(j=0;j<m;j++)
             cout<<score[i][j]<<" ";
       cout<<" 总分 "<<score[i][m]<<" ";
                       sum=score[i][m];
       b=float(sum/100.0);
                      if(b<=m&&b>=(0.9*m))
             cout<<" 非常优秀!"<<endl;
          else if(b>=(0.8*m)&&b<(0.9*m))
                      cout<<" 良好!"<<endl;
          else if(b<(0.8*m)&&b>=(0.6*m))
             cout<<" 及格!"<<endl;
          else
             cout<<" 不及格!"<<endl;
   }
  }
     cout<<endl;
}
void axmdx(int n,float x[],char str[],char num[][P],char name[][P])
{
 int k,i;
    float s;
 char nu[P];
 char na[P];
     if(n==1)
  {
        cout<<"学号 "<<num[0]<<"  姓名 "<<name[0]<<"  "<<str<<"分数 "<<x[0];
      switch(int(x[0]/10))
    { 
      case 10:
      case  9:     cout<<"   非常优秀!"<<endl;//说明输出一定要放在最后面
             break;
         case  8:
      case  7:     cout<<"   优良!"<<endl;
             break;
      case  6:     cout<<"   及格!"<<endl;
             break;
      case  5:
      case  4:
      case  3:
      case  2:
      case  1:
      case  0:     cout<<"   不及格!"<<endl;
             break;
   }

  }
  else
  {
   for(i=0;i<n-1;i++)
   for(k=i+1;k<n;k++)
   {
    if(strcmp(name[i],name[k])>0)
    {
                  strcpy(na,name[i]);
            strcpy(name[i],name[k]);
            strcpy(name[k],na);
            strcpy(nu,num[i]);
            strcpy(num[i],num[k]);
            strcpy(num[k],nu);
      s=x[i];
      x[i]=x[k];
      x[k]=s;
    }
   }
   for(i=0;i<n;i++)
   {
       cout<<"学号 "<<num[i]<<"  姓名 "<<name[i]<<"  "<<str<<"分数 "<<x[i];
    switch(int(x[i]/10))
    { 
      case 10:
      case  9:     cout<<"  非常优秀!"<<endl;//说明输出一定要放在最后面
             break;
         case  8:
      case  7:     cout<<"  优良!"<<endl;
            break;
      case  6:     cout<<"  及格!"<<endl;
            break;
      case  5:
      case  4:
      case  3:
      case  2:
      case  1:
      case  0:     cout<<"  不及格!"<<endl;
            break;
    }

   }
  }
   cout<<endl;
}
void yxmxs(int n,int m,float score[][M],char num[][P],char name[][P])
{
    char na[P];
 int i,j;
 float b;
 float sum;
    float sun;
 char x='y';
 cout<<endl;
 for(i=0;i<n;i++)
   {
          sun=0;
     for(j=0;j<m;j++) 
        sun+=score[i][j]; 
        score[i][m]=sun;
   }
 while(x!='N'&&x!='n')
 {
  cout<<endl;
  cout<<"请输入姓名 ";
     cin>>na;
     for(i=0;i<n;i++)
  {
     if(strcmp(name[i],na)==0)//用来判断两个字符串相等
     {
             cout<<"学号 "<<num[i]<<" 姓名 "<<name[i]<<" 分数 ";
             for(j=0;j<m;j++)
             cout<<score[i][j]<<" ";
       cout<<"总分 "<<score[i][m]<<" ";//补充成绩分层
          sum=score[i][m];
       b=float(sum/100.0);
                      if(b<=m&&b>=(0.9*m))
             cout<<" 非常优秀!"<<endl;
          else if(b>=(0.8*m)&&b<(0.9*m))
                      cout<<" 良好!"<<endl;
          else if(b<(0.8*m)&&b>=(0.6*m))
             cout<<" 及格!"<<endl;
          else
             cout<<" 不及格!"<<endl;
     }
  }
  cout<<endl;
  cout<<"要继续进行姓名形式查找学生信息按任意键否则输入N或n";
  cin>>x;
 }
 cout<<endl;
}
void mian()
{   int n,c,i;
 float x[1000];
 char s;
 char str[P];
 char num[N][P];
 char name[N][P];
   cout<<endl;
   cout<<"要进行成绩输入和统计输入Y或y否则N或n 选择; ";
      cin>>s;
     while(s!='N'&&s!='n')
  {
  cout<<endl;
        cout<<"科目: ";
        cin>>str;
     cout<<"请输入学生数量n=";
     cin>>n;
     for(i=0;i<n;i++)
  {
    cout<<"学号 ";
    cin>>num[i];
    cout<<"姓名 ";
    cin>>name[i];
    cout<<"分数 ";
    cin>>x[i];
   }
       while(s!='N'&&s!='n')
  {
    cout<<"寻找学生最优成绩输入(1) 最差成绩输入(2) 平均成绩输入(3)"<<endl;
    cout<<"成绩评优输入(4) 成绩大小排序输入(5) 查找学生信息输入(6) "<<endl;
    cout<<"按姓名大小排序(能咨询总体情况) (7)"<<endl;
       cout<<"选择c(1->6)=";
    cin>>c;
    cout<<endl;
           switch(c)
     {
         case 1: cout<<str<<"最优成绩: "<<max(x,n)<<endl;
         break;
         case 2: cout<<str<<"最差成绩: "<<mix(x,n)<<endl;
         break;
         case 3: cout<<str<<"平均成绩: "<<average(x,n)<<endl;//看x后面没有[];;
          break; 
            case 4: fenceng(x,n,num,name);
            break;
  
            case 5: lcp(x,n,num,name,str);
            break;
      case 6: caizao(x,n,num,name);
         break;
   case 7: axmdx(n,x,str,num,name);
     }
       cin.get();//接收回车键enter;
    cout<<endl;
       cout<<"是否要继续输入Y或y否则N或n 选择;";
    cin>>s;
  }
           //cin.get();//接收回车键enter;
     cout<<endl;
        cout<<"是否要进行另一科成绩的输入和统计输入Y或y否则N或n 选择;";
        cin>>s;
  }
  cout<<endl;
}
void lcp(float x[],int n,char num[][P],char name[][P],char str[])
{
    int i,k;
 float sco;
 char nu[P];
 char na[P];
 float sum=0;
   cout<<endl;
   cout<<"<<单科成绩排序>>"<<endl;
   cout<<endl;
     for(i=0;i<n-1;i++)
  {   
       for(k=i+1;k<n;k++)
    {   
         if(x[i]<x[k])
   {
     sco=x[i];//注意这里是j-1;
        x[i]=x[k];
     x[k]=sco;
     strcpy(na,name[i]);
     strcpy(name[i],name[k]);
     strcpy(name[k],na);
     strcpy(nu,num[i]);
     strcpy(num[i],num[k]);
     strcpy(num[k],nu);
   }
    }
  }
  for(i=0;i<n;i++)
  {
  sum+=x[i];
  cout<<"学号 "<<num[i]<<" 姓名 "<<name[i]<<" 分数 "<<x[i]<<endl;
  }
  cout<<str<<"平均分 "<<sum/n<<endl;
  cout<<endl;
}
void fenceng(float x[],int n,char num[][P],char name[][P])
{
 int i;
 cout<<endl;
 for(i=0;i<n;i++)
    {
  switch(int(x[i]/10))
  { 
  case 10:
  case  9:     cout<<"学号 "<<num[i]<<" 姓名 "<<name[i]<<" 分数 "<<x[i]<<"非常优秀!"<<endl;//说明输出一定要放在最后面
             break;
  case  8:
  case  7:     cout<<"学号 "<<num[i]<<" 姓名 "<<name[i]<<" 分数 "<<x[i]<<"优良!"<<endl;
            break;
  case  6:     cout<<"学号 "<<num[i]<<" 姓名 "<<name[i]<<" 分数 "<<x[i]<<"及格!"<<endl;
            break;
  case  5:
  case  4:
  case  3:
  case  2:
  case  1:
  case  0: cout<<"学号 "<<num[i]<<" 姓名 "<<name[i]<<" 分数 "<<x[i]<<"不及格!"<<endl;
            break;
  }

 }
 cout<<endl;
}
float max(float x[],int n)
{
     int i;
  float max;
         max=x[0];
  for(i=1;i<n;i++)
  {
   if(max<=x[i])
    max=x[i];
  }
    return max;
    return max;
}
float mix(float x[],int n)
{
       int i;
    float mix;
         mix=x[0];
  for(i=1;i<n;i++)
  {
   if(mix>=x[i])
    mix=x[i];
  }
  return mix;
}
float average(float x[],int n)
{
 int i;
 float sum=0;
 for(i=0;i<n;i++)
 {
  sum+=x[i];
 }
 return (sum/n);
}
void  caizao(float x[],int n,char num[][P],char name[][P])
{
    int k;
 char p='y';
 cout<<endl;
 cout<<"<<同学信息查找>>";
 cout<<endl;
 while(p!='N'&&p!='n')
 {
  cout<<endl;
        cout<<"以学号形式输入(1)或以姓名形式输入(2)";
     cin>>k;
    switch(k)
    {
     case 1: yxhxs(n,x,num,name);
       cout<<endl;
      break;
     case 2: yxmxs(n,x,num,name);
   cout<<endl;
      break;
    }
    cout<<endl;
       cout<<"要继续进行同学信息查找输入任意键否则N或n";
    cin>>p;
   }
}
void yxhxs(int n,float x[],char num[][P],char name[][P])
{

 char nu[P];
 int i;
 char s='y';
 cout<<endl;
 while(s!='N'&&s!='n')
 {
  cout<<"请输入学号 ";
     cin>>nu;
  cout<<endl;
     for(i=0;i<n;i++)
  {
     if(strcmp(num[i],nu)==0)//用来判断两个字符串相等
     {
             cout<<"学号 "<<num[i]<<" 姓名 "<<name[i]<<" 分数 ";
             cout<<x[i]<<" ";
     }
  }
  cout<<endl;
  cout<<"要继续进行学号形式查找学生信息按任意键否则输入N或n";
  cin>>s;
 }
 cout<<endl;
}
void yxmxs(int n,float x[],char num[][P],char name[][P])
{
 int i;
 char na[P];
 char s='y';
 cout<<endl;
 while(s!='N'&&s!='n')
 {
  cout<<endl;
  cout<<"请输入姓名  ";
     cin>>na;
     for(i=0;i<n;i++)
  {
     if(strcmp(name[i],na)==0)//用来判断两个字符串相等
     {
             cout<<"学号 "<<num[i]<<" 姓名 "<<name[i]<<" 分数 ";
       cout<<x[i]<<" ";
     }
  }
  cout<<endl;
  cout<<endl;
  cout<<"要继续进行姓名形式查找学生信息按任意键否则输入N或n";
  cin>>s;
 }
 cout<<endl;
}
void main()
{
 int k;
 cout<<"<<欢迎使用成绩处理程序!>>  "<<endl;
 cout<<"作者:罗振辉 "<<endl;
 cout<<endl;
 cout<<"单科处理(实用单个老师进行单科成绩处理)输入1"<<endl;
 cout<<"全科成绩处理(实用大众,多科成绩处理)输入2"<<endl;
 cout<<"请选择k=";
    cin>>k;
 switch(k)
 {
 case 1: mian();
      break;
 case 2: miin();
      break;
 }
 cout<<endl;
}
//说明;接收回车键enter;
//说明输出一定要放在最后面
//注意;这里void中不一定要有输出结果
//再设定一个函数交换num[i+1]中的值;
//求最大值可设一个函数
//在这里如果输入多个数字时,可以考虑用二维数组(char)性使用
///字符串的复制利用
//if(strcmp(num[i],nu)==0)//用来判断两个字符串相等
//sum=0;//每次副初值为0;
//成绩评优问提
//注意long  的含义::“:
//数量运算等级太差

上一篇:C/C++模仿小灵通系统


下一篇:重载与覆盖的区别