| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 296 人关注过本帖
标题:各位老师 朋友帮帮我完成这个程序 实在不会了 自学没人讲了
只看楼主 加入收藏
jiangxiaofen
Rank: 1
来 自:大连
等 级:新手上路
帖 子:5
专家分:0
注 册:2010-9-8
收藏
 问题点数:0 回复次数:0 
各位老师 朋友帮帮我完成这个程序 实在不会了 自学没人讲了
在下面的程序中增加单科成绩排名  ;输出两科成绩不及格的人的名单   程序还有很多瑕疵  帮忙修改一下  谢谢 弄完发到本人邮箱里857290175@  谢谢

#include<iostream.h>
#include<string.h >
//#include<iomanip.h>
#include<ctime>
#include<conio.h>
#include<iostream >
struct student     


//定义一个学生结构体
{
    char name[8];
    int num;
    //char add[20];
    int GS,YY,JSJ,SUM;
};

int s=0;
class student1     


//定义一个学生类
{
private:
    student  stu[40];
    char  name;
    int num;
    int  GS,YY,JSJ,SUM;   
   
public:
    void sr(char *,int,/*char *,*/int,int,int);
    void print(int);
    int jc(int xxh)
    {
        
        int m=0;
        while(m<=s+1)
            if(xxh==stu[m++].num)
                break;
            if(m>s+1)
                return 0;
            else
                return 1;
    }
    void cz(int);
    void sc(int);
    void sum(int);
};


void  
student1::sr(char *xm,int xh,/*char *dz,*/int gs,int yy,int jsj)//输入模块
{
    strcpy(stu[s].name,xm);
    stu[s].num=xh;
//    strcpy(stu[s].add,dz);
    stu[s].GS=gs;
    stu[s].YY=yy;
    stu[s].JSJ=jsj;
}
//////////////////////////////////////////////////输出模块/////////////////////////////////////////////////////////
void  student1::print(int s)        
{
   
/*    cout<<s<<"\t";
   
    cout<<stu[s].name<<"\t";
   
    cout<<stu[s].num<<"\t";
   
/////    cout<<stu[s].add<<"\t";
   
    cout<<stu[s].GS<<"\t";
   
    cout<<stu[s].YY<<"\t";
   
    cout<<stu[s].JSJ<<"\t";
   
    cout<<endl;*/


   
    cout<<"***********************************************************************"<<endl;
    cout<<"   学号    姓名    高数成绩    英语成绩    计算机成绩    平均成绩   "<<endl;
    cout<<"***********************************************************************"<<endl;
    cout<<"     "<<stu[s].num<<"       "<<stu[s].name<<"        "<<stu[s].GS<<"        "<<stu[s].YY<<"        "<<stu[s].JSJ<<endl;
    cout<<"***********************************************************************"<<endl;
}
////////////////////////////////////////////////////////查找模块////////////////////////////////////////////////////////////
void  student1::cz(int s)
{
    int  xxh,p;
    while(s==0)
    {
        
        cout<<"没有记录,请先输入记录!"<<endl;
        break;
    }
    if(s!=0)
    {
        cout<<" 请输入您要查找的学号:";  
        cin>>xxh;
        while  
            (xxh<0||xxh>1000) //判断输入的学号是否正确
        {
            
            cout<<"您输入的学号不正确,请重新输入学号"<<endl;
            cin>>xxh;
        }
        while(s!=0)//查找是否有符合条件的记录
        {
            
            p=1;
            
            if (xxh==stu[s].num)
            {  
               
        
            //    cout<<"姓名\t学号\t地址\t高数\t英语\t计算机"<<endl;
                cout<<"***********************************************************************"<<endl;
                cout<<"   学号    姓名    高数成绩    英语成绩    计算机成绩    平均成绩   "<<endl;
                cout<<"***********************************************************************"<<endl;
                cout<<"  %5d   "<<stu[s].num<<"%10s    "<<stu[s].name<<"%5.2f    "<<stu[s].GS<<"%5.2f    "<<stu[s].YY<<"%5.2f    "<<stu[s].JSJ<<endl;
                cout<<"***********************************************************************"<<endl;
            //    cout<<stu[s].name<<"\t";
            //    cout<<stu[s].num<<"\t";
            //   
            //    cout<<stu[s].add<<"\t";
            //   
            //    cout<<stu[s].GS<<"\t";
            //   
            //    cout<<stu[s].YY<<"\t";
            //   
            //    cout<<stu[s].JSJ<<endl;
               
                getch();
               
                break;
            }
            
            else
                p=0;
            s--;
        }
        if(p==0)
            
            cout<<"很抱歉,没有找到您要查找的学号!"<<endl;}
    getch();
}

void  
student1::sc(int n) //删除模块
{
    int xxh,p;
    char da;
    while(s==0)
    {
        
        cout<<"没有记录,请先输入记录!"<<endl;
        break;
    }
    if(s!=0)
    {
        
        cout<<"请输入您要删除的学号:";
        cin>>xxh;
        
        while(xxh<0||xxh>1000)
        {
            
            cout<<"您输入的学号不正确,请您输入一个六位数的学号"<<endl;
            cin>>xxh;
        }
        
        
        for(int i=1;i<=n;i++)
        {
            
            if(stu[i].num!=xxh)
               
                p=0;
            
            if(stu[i].num==xxh)
               
            {
               
                cout<<"姓名\t学号\t地址\t高数\t英语\t计算机"<<endl;
                cout<<stu[i].name<<"\t";
                cout<<stu[i].num<<"\t";
////                cout<<stu[i].add<<"\t";
                cout<<stu[i].GS<<"\t";
                cout<<stu[i].YY<<"\t";
                cout<<stu[i].JSJ<<endl;
                cout<<"您确实要删除该学生的记录吗?(y/n)";
                cin>>da;
                if(da=='y'||da=='Y')//3
                {
                    for(int j=i;j<=n-1;j++) // 删除记录
                    {
                        strcpy(stu[j].name,stu[j+1].name);
                        stu[j].num=stu[j+1].num;
////                        strcpy(stu[j].add,stu[j+1].add);
                        stu[j].GS=stu[j+1].GS;
                        stu[j].YY=stu[j+1].YY;
                        stu[j].JSJ=stu[j+1].JSJ;
                    }
                    cout<<"该记录已删除!"<<endl;
                    s=s-1;
                    p=1;
                    break;
                }//if3
                else
                {
                    cout<<"该记录未删除!"<<endl;
                    p=1;
                }
            }
        }//for(int i=1;i<=n;i++)
        if(p==0)
            cout<<"很抱歉,没有找到您要找的学号!"<<endl;
    }//if(s!=0)
    getch();
}


////////////////////////////////排序模块/////////////////////////////////////////////////////////////////
void student1::sum(int s)               
{
    int chang;
    int b[40];
    while(s==0)
    {
        
        cout<<"没有记录,请先输入记录!"<<endl;
        break;
    }
    if(s!=0)
    {
        
        cout<<"姓名\t学号\t地址\t英语\t";
        
        cout<<"高数\t计算机\t总分"<<endl;
        
        
        for(int k=1;k<=s;k++)
        {
            
            b[k]=stu[k].GS+stu[k].YY+stu[k].JSJ;
            stu[k].SUM=stu[k].GS+stu[k].YY+stu[k].JSJ;
        }
        
        for(int i=1;i<=s;i++)  //利用冒泡法对B[]进行排序
            
            for(int j=1;j<=s-i;j++)
               
                if(b[j]<b[j+1])
                    
                {
                    chang=b[j];
                    b[j]=b[j+1];
                    b[j+1]=chang;
                }
               
                for(int h=1;h<=s;h++)    //输出与B[]中相同总分所对应的内容
                    for(int e=1;e<=s;e++)
                        if(b[h]==stu[e].SUM)
                        {
                            cout<<stu[e].name<<"\t";
                            cout<<stu[e].num<<"\t";
////                            cout<<stu[e].add<<"\t";
                            cout<<stu[e].YY<<"\t";
                            cout<<stu[e].GS<<"\t";
                            cout<<stu[e].JSJ<<"\t";
                            cout<<stu[e].SUM<<endl;
                        }
    }
   
    getch();
}


void main()
{
    student1  st;
    char da,a;
    char *xm;
    int  gs,yy,jsj,xh;
    time_t t;
    time(&t);
    while(1)
    {
        
        system("cls");
        
        cout<<"\n\t\t\t学生成绩管理系统\n\t\t\n"<<endl;
        cout<<"\t**显示系统时间和日期:"<<ctime(&t)<<endl;
        cout<<"\t************************主菜单栏*********************\n"<<endl;
        cout<<"\t*****\t1.添加学生信息\t*****\t2.显示学生信息\t*****\n"<<endl;
        cout<<"\t*****\t3.查找学生信息\t*****\t4.删除学生信息\t*****\n"<<endl;
        cout<<"\t*****\t5.单科成绩排序\t*****\t6.退出程序\t*****\n"<<endl;
        cout<<"\t************************主菜单栏*********************\n"<<endl;
        cout<<"\t\t\t\t选择功能选项:";
        cin>>a;
t:  if(a=='6')  
        break;
    switch(a)
    {
    case '1':
        system("cls");
        {
            
            //    cout<<"请依次输入学生的姓名,学号, 地址,高数,英语,计算机:"<<endl;
            
            xm=new char[];
            
            //dz=new char[];
            cout<<"姓名";
            cin>>xm;
            cout<<"\n学号:";
            cin>>xh;
            cout<<"\n高数成绩:";
            cin>>gs;
            cout<<"\n英语成绩:";
            cin>>yy;
            cout<<"\n计算机成绩:";
            cin>>jsj;
            //    cin>>xm>>xh>>dz>>gs>>yy>>jsj;
            
            while(st.jc(xh))  //调用JC模块判断学号是否重复
               
            {
               
                cout<<"学号重复,请重新输入!"<<endl;
               
                cin>>xh;
               
            }
            
            s=s+1;
            
            st.sr(xm,xh,/*dz,*/gs,yy,jsj);
            
            cout<<"\n是否继续输入?(y/n)";
            
            cin>>da;
            
            while (da=='y'||da=='Y')      //判断是否要继续输入
               
            {      
               
                //cout<<"请依次输入学生的姓名,学号,地址,高数,英语,计算机:"<<endl;
                xm=new char[];
            //    dz=new char[];
                //    cin>>xm>>xh>>dz>>gs>>yy>>jsj;
                cout<<"\n姓名";
                cin>>xm;
                cout<<"\n学号:";
                cin>>xh;
                cout<<"\n高数成绩:";
                cin>>gs;
                cout<<"\n英语成绩:";
                cin>>yy;
                cout<<"\n计算机成绩:";
                cin>>jsj;
                while(st.jc(xh))
                {
                    cout<<"学号重复,请重新输入!"<<endl;
                    cin>>xh;
                }
                s=s+1;
                st.sr(xm,xh,/*dz,*/gs,yy,jsj);
                cout<<"\n是否继续输入?(y/n)";
                cin>>da;
            }
            getch();
        };break;
        
    case '2':
        system("cls");
        {
            
            if(s==0)    //判断是否有记录输入
               
            {
                cout<<"没有记录,请先输入记录!"<<endl;
                getch();
                break;
            }
            if(s!=0)
            {
            /*/    cout<<"序号"<<"\t";
                cout<<"姓名"<<"\t";
                cout<<"学号"<<"\t";
                //cout<<"地址"<<"\t";
                cout<<"高数"<<"\t";
                cout<<"英语"<<"\t";
                cout<<"计算机"<<endl;*/
                for(int i=1;i<=s;i++)
                    st.print(i);
                getch();
            }
        };break;
    case '3':
        system("cls");
        st.cz(s);break;
    case '4':
        system("cls");
        st.sc(s);break;
    case '5':
        system("cls");
        st.sum(s);break;
                default:
                    {
                        while(a=='0'||a>'6')         //判断选项是否正确
                           
                        {
                           
                            cout<<"错误选项,请重新选择!"<<endl;
                            cin>>a;
                           
                        }
                        
                        goto t;
                        
                    };break;
    }
    }
    cout<<"谢谢您的使用!"<<endl;
}
搜索更多相关主题的帖子: 老师 自学 朋友 
2010-09-12 20:40
快速回复:各位老师 朋友帮帮我完成这个程序 实在不会了 自学没人讲了
数据加载中...
 
   



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

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