| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 357 人关注过本帖
标题:请帮忙找出修改其中的错误
只看楼主 加入收藏
一等战将
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-7-2
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
请帮忙找出修改其中的错误
#include<iostream.h>           
#include<string.h>
#include<stdlib.h>
#define NULL 0
struct NODE
{
    long int num;                         //学号.
    char name[20];                        //姓名.
    char sex[20];                         //性别.
    char place[20];                       //籍贯.
    float c;                        //VC++成绩.
    float en;                      //英语成绩.
    float ma;                     //高数成绩.
    NODE  *next;                       //指向下一个结点的指针.
};
NODE *create(int n)                      //输入函数.
{
    NODE *p,*pend,*h=NULL;
    int i=0;
    if(n<1)return NULL;
    cout<<"学号  姓名  性别  籍贯  VC++成绩  英语成绩  高数成绩"<<endl;
    while(i<n)
    {
        p=new NODE;
        cin>>p->num>>p->name>>p->sex>>p->place>>p->c>>p->en>>p->ma;
        p->next=NULL;
        if(h==NULL){h=p;pend=p;}
        else{pend->next=p;pend=p;}
        i++;
    }
    return h;
}
void print(NODE *h)
{
    NODE *p;
    p=h;
    cout<<"学号    姓名    性别    籍贯  vc++成绩  英语成绩  高数成绩"<<endl;
    while(p!=0)
    {
        cout<<p->num<<'\t'<<p->name<<'\t'<<p->sex<<'\t'<<p->place<<'\t'<<p->c<<'\t'<<p->en<<'\t'<<p->ma<<endl;
        p=p->next;
    }
}
void count(NODE *h,int n)                  //计算成绩函数.
{
    float  S[20],aver[20],aver1=0,aver2=0,aver3=0,MAX,max1,max2,max3;
    float s1[20],s2[20],s3[20];
    NODE *p;
    p=h;
    for(int i=0;i<n;i++)
    {
       S[i]=p->c+p->en+p->ma;
       aver[i]=S[i]/3;
       p=p->next;}
       for(p=h,i=0;i<n;i++)
       {
           aver1+=p->c;aver2+=p->en;aver3+=p->ma;p=p->next;
       }
       aver1=aver1/n;
       aver2=aver2/n;
       aver3=aver3/n;
       for(p=h,i=0;i<n;i++){s1[i]=p->c;s2[i]=p->c;s3[i]=p->ma;p=p->next;}
       MAX=0;max1=0;max2=0;max3=0;
      for(i=0;i<n;i++)
      {
          if(MAX<S[i])MAX=S[i];
          if(max1<s1[i])max1=s1[i];
          if(max2<s2[i])max2=s2[i];
          if(max3<s3[i])max3=s3[i];
      }
      cout<<"总成绩最高的学生:"<<'\n';
      for(p=h,i=0;i<n;i++)
      {
          if(MAX==S[i])cout<<p->num<<'\t'<<p->name<<'\t'<<MAX<<endl;p=p->next;
      }
      cout<<"VC++成绩最高的学生:"<<'\n';
      for(p=h,i=0;i<n;i++){if(max1==s1[i])cout<<p->num<<'\t'<<p->name<<'\t'<<max1<<endl;p=p->next;}
      cout<<"英语成绩最高的学生:"<<'\n';
      for(p=h,i=0;i<n;i++){if(max2==s2[i])cout<<p->num<<'\t'<<p->name<<'\t'<<max2<<endl;p=p->next;}
      cout<<"高数成绩最高的学生:"<<'\n';
      for(p=h,i=0;i<n;i++){if(max3==s3[i])cout<<p->num<<'\t'<<p->name<<'\t'<<max3<<endl;p=p->next;}
}
void search(NODE *h)                              //搜索函数
{
    NODE *p;
    p=h;
    int r,t;
    char name[10];
    cout<<"按学号查询请输入1,按姓名查询请输入2!"<<endl;
    cin>>r;
    switch(r)
    {
    case 1:
        {
           cout<<"请输入要查询的学号:"<<endl;
           cin>>t;
           while(p!=0)
           {
            if(p->num==t)
            {
                cout<<"学号    姓名    性别    籍贯  vc++成绩 英语成绩 高数成绩"<<endl;
                cout<<p->num<<'\t'<<p->name<<'\t'<<p->sex<<'\t'<<p->place<<'\t'<<p->c<<'\t'<<p->en<<'\t'<<p->ma<<endl;
                break;
            }
            else p=p->next;
           }
        }break;
    case 2:
        {
            cout<<"请输入要查询的姓名:"<<endl;
            cin>>name;
            while(p!=0)
            {
                if( strcmp(name,p->name)==0)
                {
                     cout<<"学号    姓名    性别    籍贯  vc++成绩 英语成绩 高数成绩"<<endl;
                    cout<<p->num<<'\t'<<p->name<<'\t'<<p->sex<<'\t'<<p->place<<'\t'<<p->c<<'\t'<<p->en<<'\t'<<p->ma<<endl;
                    break;
                }
                else p=p->next;
            }
        }
    }
}
void LOW(NODE *h,int a,int n)                      //排序函数.
{
    NODE *p,*p1,*p2;
    long int NUM;
    char NAME[20],SEX[20],PLACE[20];
    float S[20],aver[20],CSCORE,CENGLISH,CMAYSICS;
    p=h;
for(int i=0;i<n;i++)
{
    S[i]=p->c+p->en+p->ma;
    aver[i]=S[i]/3;
p=p->next;
}
    cout<<"请选择排序方式!"<<endl;
   
    cout<<"按姓名排序请输入1"<<endl;
    cout<<"按VC++成绩排序请输入2"<<endl;
    cout<<"按英语成绩排序请输入3"<<endl;
    cout<<"按高数成绩排序请输入4"<<endl;
    cout<<"按总成绩排序请输入5"<<endl;
    cout<<"按平均成绩排序请输入6"<<endl;
    cin>>a;
switch(a)                                      
{
case 1:if(h==0)cout<<"无结点"<<'\n';
    else {
        p1=h;
        while(p1->next!=0)                            //可能有问题
        for(  i=0;i<n-1;i++)
        {
            p2=p1->next;
            {
                for(int j=i+1;j<n;j++)
                {
                    if(strcmp(p1->name,p2->name)==1)
                    {
                        NUM=p1->num;p1->num=p2->num;p2->num=NUM;strcpy(NAME,p1->name);strcpy(p1->name,p2->name);
                        strcpy(p2->name,NAME);
                        strcpy(SEX,p1->sex);strcpy(p1->sex,p2->sex);strcpy(p2->sex,SEX);
                        strcpy(PLACE,p1->place);strcpy(p1->place,p2->place);strcpy(p2->place,PLACE);
                        CSCORE=p1->c;p1->c=p2->c;p2->c=CSCORE;
                        CENGLISH=p1->en;p1->en=p2->en;p2->en=CENGLISH;
                        CMAYSICS=p1->ma; p1->ma=p2->ma; p2->ma=CMAYSICS;
                    }
                    p2=p2->next;
                }
                p1=p1->next;
            }
        }
    }
    p=h;
    for( i=0;i<n;i++)
    {
        cout<<p->num<<'\t'<<p->name<<'\t'<<p->sex<<'\t'<<p->place<<'\t'<<p->c<<'\t'<<p->en<<'\t'<<p->ma<<'\n';
        p=p->next;
    }
    cout<<endl;break;
case 2:if(h==0)cout<<"无结点"<<'\n';
    else
    {
        p1=h;
        while(p1->next!=0)
        for(i=0;i<n-1;i++)
        {
            p2=p1->next;
            for(int j=i+1;j<n;j++)
            {
                if(p1->c>=p2->c)
                {
                    NUM=p1->num;p1->num=p2->num;p2->num=NUM;strcpy(NAME,p1->name);strcpy(p1->name,p2->name);
                    strcpy(p2->name,NAME);strcpy(SEX,p1->sex);strcpy(p1->sex,p2->sex);strcpy(p2->sex,SEX);
                    strcpy(PLACE,p1->place);strcpy(p1->place,p2->place);strcpy(p2->place,PLACE);
                    CSCORE=p1->c;p1->c=p2->c;p2->c=CSCORE;CENGLISH=p1->en;p1->en=p2->en;p2->en=CENGLISH;
                    CMAYSICS=p1->ma; p1->ma=p2->ma; p2->ma=CMAYSICS;
                }
               p2=p2->next;
            }
            p1=p1->next;
        }
    }
    p=h;
    for(i=0;i<n;i++)
    {
        cout<<p->num<<'\t'<<p->name<<'\t'<<p->sex<<'\t'<<p->place<<'\t'<<p->c<<'\t'<<p->en<<'\t'<<p->ma<<'\n';
        p=p->next;
    }
    cout<<endl;break;
case 3:if(h==0)cout<<"无结点"<<'\n';
    else
    {
        p1=h;
        while(p1->next!=0)
        for( i=0;i<n-1;i++)
        {
            p2=p1->next;
           {
               for(int j=i+1;j<n;j++)
               {
                   if(p1->en>=p2->en)
                   {
                       NUM=p1->num;p1->num=p2->num;p2->num=NUM;
                       strcpy(NAME,p1->name);strcpy(p1->name,p2->name);strcpy(p2->name,NAME);
                       strcpy(SEX,p1->sex);strcpy(p1->sex,p2->sex);strcpy(p2->sex,SEX);
                       strcpy(PLACE,p1->place);strcpy(p1->place,p2->place);strcpy(p2->place,PLACE);
                       CSCORE=p1->c;p1->c=p2->c;p2->c=CSCORE;
                       CENGLISH=p1->en;p1->en=p2->en;p2->en=CENGLISH;
                       CMAYSICS=p1->ma; p1->ma=p2->ma; p2->ma=CMAYSICS;
                   }
                   p2=p2->next;
               }
               p1=p1->next;
           }
        }
    }
    p=h;
    for(i=0;i<n;i++)
    {
        cout<<p->num<<'\t'<<p->name<<'\t'<<p->sex<<'\t'<<p->place<<'\t'<<p->c<<'\t'<<p->en<<'\t'<<p->ma<<'\n';
        p=p->next;
    }
    cout<<endl;break;
case 4:if(h==0)cout<<"无结点"<<'\n';
    else
    {
        p1=h;
        while(p1->next!=0)
        for(i=0;i<n-1;i++)
        {
            p2=p1->next;
            {
                for(int j=i+1;j<n;j++)
                {
                    if(p1->c>=p2->c)
                    {
                        NUM=p1->num;p1->num=p2->num;p2->num=NUM;
                        strcpy(NAME,p1->name);strcpy(p1->name,p2->name);strcpy(p2->name,NAME);
                        strcpy(SEX,p1->sex);strcpy(p1->sex,p2->sex);strcpy(p2->sex,SEX);
                        strcpy(PLACE,p1->place);strcpy(p1->place,p2->place);strcpy(p2->place,PLACE);
                        CSCORE=p1->c;p1->c=p2->c;p2->c=CSCORE;CENGLISH=p1->en;p1->en=p2->en;p2->en=CENGLISH;
                        CMAYSICS=p1->ma; p1->ma=p2->ma; p2->ma=CMAYSICS;
                    }
                    p2=p2->next;
                }
                p1=p1->next;
            }
        }
    }
    p=h;
    for(i=0;i<n;i++)
    {
        cout<<p->num<<'\t'<<p->name<<'\t'<<p->sex<<'\t'<<p->place<<'\t'<<p->c<<'\t'<<p->en<<'\t'<<p->ma<<'\n';
        p=p->next;
    }
    cout<<endl;break;
case 5:if(h==0)cout<<"无结点"<<'\n';
    else
    {
        p1=h;
        while(p1->next!=0)
        for( i=0;i<n-1;i++)
        {
            p2=p1->next;
            {
                for(int j=i+1;j<n;j++)
                {
                    if(S[i]>=S[j])
                    {
                        NUM=p1->num;p1->num=p2->num;p2->num=NUM;
                        strcpy(NAME,p1->name);strcpy(p1->name,p2->name);strcpy(p2->name,NAME);
                        strcpy(SEX,p1->sex);strcpy(p1->sex,p2->sex);strcpy(p2->sex,SEX);
                        strcpy(PLACE,p1->place);strcpy(p1->place,p2->place);strcpy(p2->place,PLACE);
                        CSCORE=p1->c;p1->c=p2->c;p2->c=CSCORE;
                        CENGLISH=p1->en;p1->en=p2->en;p2->en=CENGLISH;
                        CMAYSICS=p1->ma; p1->ma=p2->ma; p2->ma=CMAYSICS;
                    }
                    p2=p2->next;
                }
                p1=p1->next;
            }
        }
    }
    p=h;
    for(i=0;i<n;i++)
    {
        cout<<p->num<<'\t'<<p->name<<'\t'<<p->sex<<'\t'<<p->place<<'\t'<<p->c<<'\t'<<p->en<<'\t'<<p->ma<<'\n';
        p=p->next;
    }
    cout<<endl;break;
case 6:if(h==0)cout<<"无结点"<<'\n';
    else
    {
        p1=h;
        while(p1->next!=0)
        for( i=0;i<n-1;i++)
        {
            p2=p1->next;
            {
                for(int j=i+1;j<n;j++)
                {
                    if(aver[i]>=aver[j])
                    {
                        NUM=p1->num;p1->num=p2->num;p2->num=NUM;
                        strcpy(NAME,p1->name);strcpy(p1->name,p2->name);strcpy(p2->name,NAME);
                        strcpy(SEX,p1->sex);strcpy(p1->sex,p2->sex);strcpy(p2->sex,SEX);
                        strcpy(PLACE,p1->place);strcpy(p1->place,p2->place);strcpy(p2->place,PLACE);
                        CSCORE=p1->c;p1->c=p2->c;p2->c=CSCORE;
                        CENGLISH=p1->en;p1->en=p2->en;p2->en=CENGLISH;
                        CMAYSICS=p1->ma; p1->ma=p2->ma; p2->ma=CMAYSICS;
                    }
                    p2=p2->next;
                }
                p1=p1->next;
            }
        }
    }
    p=h;
    for(i=0;i<n;i++)
    {
        cout<<p->num<<'\t'<<p->name<<'\t'<<p->sex<<'\t'<<p->place<<'\t'<<p->c<<'\t'<<p->en<<'\t'<<p->ma<<'\n';
        p=p->next;
    }
    cout<<endl;break;
default: cout<<"无可排序的依据!"<<endl;
 }
}
void deletenode(NODE *h,int data)                   //删除学生信息函数.
{
    NODE *p1,*p2;
    int b;
    cout<<"如果要删除学生的信息请输入1!"<<'\n'<<"如果不需要删除学生的信息请输入2!"<<endl;
    cin>>b;
    switch(b)
    {
    case 1:
           cout<<"输入要删除信息学生的学号:"<<endl;
           cin>>data;
           if(h==NULL)cout<<"无学生信息不能删除!";
           if(h->num==data)
           {
             p2=h;h=h->next;
             delete p2;cout<<"成功删除学生的信息!"<<endl;
           }
         else
         {
            p2=p1=h;
            while(p2->num!=data&&p2->next!=NULL)
            {
               p1=p2;p2=p2->next;
            }
            if(p2->num==data)
            {
             p1->next=p2->next;delete p2;cout<<"成功删除学号为"<<data<<"学生的信息"<<endl;
            }
         else cout<<"没有找到要删除的信息";
         }
    case 2:
        break;
    }
}
void score(NODE *h,int n)                 //学分积点计算及奖学金评定函数.
{
    NODE *p;
    char name[20][20],sex[20][20],place[20][20],b[20],c[20],d[20];
    double s[20],num[20],cscore[20],cenglish[20],cmaysics[20],S,a,e,f,g;
    p=h;
    for(int i=0;i<n;i++)
    {
        s[i]=((p->c*4.5+p->en*4+p->ma*3)/11.5-50)/10;
        num[i]=p->num;strcpy(name[i],p->name);
        strcpy(sex[i],p->sex);strcpy(place[i],p->place);
        cscore[i]=p->c;cscore[i]=p->c;cmaysics[i]=p->ma;
        p=p->next;
    }
    for(i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(s[i]<=s[j])
            {
                S=s[i];s[i]=s[j];s[j]=S;
                a=num[i];num[i]=num[j];num[j]=a;strcpy(b,name[i]);
                strcpy(name[i],name[j]);strcpy(name[j],b);strcpy(c,sex[i]);
                strcpy(sex[i],sex[j]);strcpy(sex[j],c);strcpy(d,place[i]);
                strcpy(place[i],place[j]);strcpy(place[j],d);e=cscore[i];
                cscore[i]=cscore[j];cscore[j]=e;f=cenglish[i];cenglish[i]=cenglish[j];
                cenglish[j]=f;g=cmaysics[i];cmaysics[i]=cmaysics[j];cmaysics[j]=g;
            }
        }
    }
   
    for(i=0;i<n;i++)cout<<num[i]<<'\t'<<name[i]<<'\t'<<s[i]<<'\n';
    cout<<"特等奖学金名单:"<<'\n';
    for(i=0;i<n;i++)
    {
        if(s[i]>=4.0)
        cout<<name[i]<<'\n';
    }
    cout<<"一等奖学金名单:"<<'\n';
    for(i=0;i<n;i++)
    {
        if(s[i]>=3.6&&s[i]<4.0)
        cout<<name[i]<<'\n';
    }
    cout<<"二等奖学金名单:"<<'\n';
    for(i=0;i<n;i++)
    {
        if(s[i]>=3.2&&s[i]<3.6)
        cout<<name[i]<<'\n';
    }
    cout<<"三等奖学金名单:"<<'\n';
    for(i=0;i<n;i++)
    {
        if(s[i]>=2.8&&s[i]<3.2)
            cout<<name[i]<<'\n';
    }
}

void goodstudent(NODE *h,int n)               //三好学生评定函数.
{
    double s[20];
    char NAME[20][20];
    long int  NUM[20];
    NODE *p;
    p=h;
    for(int i=0;i<n;i++)
    {
        s[i]=((p->c*4.5+p->en*4+p->ma*3)/11.5-50)/10;
        strcpy(NAME[i],p->name);NUM[i]=p->num;
        p=p->next;
    }
   cout<<"三好学生的名单:"<<'\n';
   for(i=0;i<n;i++)
   

}

搜索更多相关主题的帖子: long 英语成绩 include 
2012-07-02 08:25
Catan
Rank: 2
等 级:论坛游民
帖 子:8
专家分:46
注 册:2012-6-27
收藏
得分:20 
好长的代码,吓人啊
2012-07-02 17:40
快速回复:请帮忙找出修改其中的错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020242 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved