| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 377 人关注过本帖
标题:各位大虾,问一下这代码有什么错误。
只看楼主 加入收藏
hamdgem
Rank: 1
等 级:新手上路
帖 子:4
专家分:3
注 册:2010-4-18
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:3 
各位大虾,问一下这代码有什么错误。
#include<iostream.h>
//类界面
class    STUDENT {
public:
        STUDENT(char name[15],char number[9],char major[15]);//学生的名字,学号和专业
        ~STUDENT();
        char name[15],number[9],major[15];
};
class    ATTENDANCE{
public:
        float att_mark(int zhdfsh1,int dmcsh,int ddcsh);//(占的分数,点名次数,到的次数)
        ATTENDANCE();
        ~ATTENDANCE();
        int zhdfsh1,dmcsh,ddcsh;
};
class    HOMEWORK{
public:
        float home_mark(int zhdfsh2,char zyqk);//(占的分数,作业情况)
        HOMEWORK();
        ~HOMEWORK();
        int zhdfsh2;
        char zyqk;
};
class    MID_EXAM{
public:
        float mid_mark(int zhdfsh3,float midmark);//(期中考占的分数,考得的成绩)
        MID_EXAM();
        ~MID_EXAM();
        int zhdfsh3;
        float midmark;
};
class    FINAL_EXAM{
public:
        float final_mark(int zhdfsh4,float fimark);
        FINAL_EXAM();
        ~FINAL_EXAM();
        int zhdfsh4;
        float fimark;
};
class STUDENT_MARK:public STUDENT,public ATTENDANCE,public HOMEWORK,public MID_EXAM,public FINAL_EXAM{
public:
        int total_mark(float att_mark,float home_mark,float mid_mark,float final_mark);
        STUDENT_MARK();        
        ~STUDENT_MARK();
        float att_mark;
        float home_mark;
        float mid_mark;
        float final_mark;
};
//类实现
STUDENT::STUDENT(char name[15],char number[9],char major[15])
    {
        cout<<"Student's name is"<<name[15]<<"\n";
        cout<<"Student's number is"<<number[9]<<"\n";
        cout<<"Student's major is"<<major[15]<<"\n";
        return;
    }
float ATTENDANCE::att_mark(int zhdfsh1,int dmcsh,int ddcsh)
    {
    return (float) zhdfsh1*ddcsh/dmcsh;
    }
float HOMEWORK::home_mark(int zhdfsh2,char zyqk)
    {
    switch (zyqk){
        case 'a':return (float) zhdfsh2;break;
        case 'b':return (float)0.9*zhdfsh2;break;
        case 'c':return (float)0.8*zhdfsh2;break;
        case 'd':return (float)0.7*zhdfsh2;break;
        case 'e':return (float)0.6*zhdfsh2;break;
        }
    }
float MID_EXAM::mid_mark(int zhdfsh3,float midmark)
    {
    return zhdfsh3*midmark;
    }
float FINAL_EXAM::final_mark(int zhdfsh4,float fimark)
    {
    return zhdfsh4*fimark;
    }
int STUDENT_MARK::total_mark(float att_mark,float home_mark,float mid_mark,float final_mark)
    {
    return (int)att_mark+home_mark+mid_mark+final_mark;
    }
STUDENT_MARK::STUDENT_MARK()
    {
    return;
    }
STUDENT_MARK::~STUDENT_MARK()
    {
    return;
    }

void main()
{
    STUDENT_MARK obj_student;
    int zhdfsh1,zhdfsh2,zhdfsh3,zhdfsh4,dmcsh,ddcsh,total_mark,totalmark;
    char name[15],number[9],major[15],zyqk;
    float att_mark,home_mark,mid_mark,final_mark;
    cout<<"请输入学生名字(英文)、学号和专业(英文)。\n";
    cin>>obj_student.name[15]>>obj_student.number[9]>>obj_student.major[15];
    cout<<"请输入点名占的分数、点名次数和已到的次数。\n";
    cin>>obj_student.zhdfsh1>>obj_student.dmcsh>>obj_student.ddcsh;
    cout<<"请输入作业占的分数和作业情况。\n";
    cout<<"(作业情况等级为a~e,为100%~60%,一一对应。\n";
    cin>>obj_student.zhdfsh2>>obj_student.zyqk;
    cout<<"请输入期中考占的分数和考得的成绩。\n";
    cin>>obj_student.zhdfsh3>>obj_student.midmark;
    cout<<"请输入期末考占的分数和考得的成绩。\n";
    cin>>obj_student.zhdfsh4>>obj_student.fimark;
    totalmark=obj_student.total_mark(obj_student.att_mark,obj_student.home_mark,obj_student.mid_mark,obj_student.final_mark);
    cout<<"该学生最终成绩为:\n"<<totalmark<<endl;
}
搜索更多相关主题的帖子: 代码 
2010-05-25 16:20
fanfan320
Rank: 3Rank: 3
来 自:运城
等 级:论坛游侠
帖 子:82
专家分:104
注 册:2010-5-12
收藏
得分:7 
#include<iostream.h>
//类界面
class    STUDENT {
public:
        STUDENT(char name[15],char number[9],char major[15]);//学生的名字,学号和专业
        ~STUDENT();
        char name[15],number[9],major[15];
};
class    ATTENDANCE{
public:
        float att_mark(int zhdfsh1,int dmcsh,int ddcsh);//(占的分数,点名次数,到的次数)
        ATTENDANCE();
        ~ATTENDANCE();
        int zhdfsh1,dmcsh,ddcsh;
};
class    HOMEWORK{
public:
        float home_mark(int zhdfsh2,char zyqk);//(占的分数,作业情况)
        HOMEWORK();
        ~HOMEWORK();
        int zhdfsh2;
        char zyqk;
};
class    MID_EXAM{
public:
        float mid_mark(int zhdfsh3,float midmark);//(期中考占的分数,考得的成绩)
        MID_EXAM();
        ~MID_EXAM();
        int zhdfsh3;
        float midmark;
};
class    FINAL_EXAM{
public:
        float final_mark(int zhdfsh4,float fimark);
        FINAL_EXAM();
        ~FINAL_EXAM();
        int zhdfsh4;
        float fimark;
};
class STUDENT_MARK:public STUDENT,public ATTENDANCE,public HOMEWORK,public MID_EXAM,public FINAL_EXAM{
public:
        int total_mark(float att_mark,float home_mark,float mid_mark,float final_mark);
        STUDENT_MARK();        
        ~STUDENT_MARK();
        float att_mark;
        float home_mark;
        float mid_mark;
        float final_mark;
};
//类实现
STUDENT::STUDENT(char name[15],char number[9],char major[15])
    {
        cout<<"Student's name is"<<name[15]<<"\n";
        cout<<"Student's number is"<<number[9]<<"\n";
        cout<<"Student's major is"<<major[15]<<"\n";
        return;
    }
float ATTENDANCE::att_mark(int zhdfsh1,int dmcsh,int ddcsh)
    {
    return (float) zhdfsh1*ddcsh/dmcsh;
    }
float HOMEWORK::home_mark(int zhdfsh2,char zyqk)
    {
    switch (zyqk){
        case 'a':return (float) zhdfsh2;break;
        case 'b':return (float)0.9*zhdfsh2;break;
        case 'c':return (float)0.8*zhdfsh2;break;
        case 'd':return (float)0.7*zhdfsh2;break;
        case 'e':return (float)0.6*zhdfsh2;break;
        }
    }
float MID_EXAM::mid_mark(int zhdfsh3,float midmark)
    {
    return zhdfsh3*midmark;
    }
float FINAL_EXAM::final_mark(int zhdfsh4,float fimark)
    {
    return zhdfsh4*fimark;
    }
int STUDENT_MARK::total_mark(float att_mark,float home_mark,float mid_mark,float final_mark)
    {
    return (int)att_mark+home_mark+mid_mark+final_mark;//这儿要加括号
    }
STUDENT_MARK::STUDENT_MARK()
    {
    return;
    }
STUDENT_MARK::~STUDENT_MARK()
    {
    return;
    }

void main()
{
    STUDENT_MARK obj_student;
    int zhdfsh1,zhdfsh2,zhdfsh3,zhdfsh4,dmcsh,ddcsh,total_mark,totalmark;
    char name[15],number[9],major[15],zyqk;
    float att_mark,home_mark,mid_mark,final_mark;
    cout<<"请输入学生名字(英文)、学号和专业(英文)。\n";
    cin>>obj_student.name[15]>>obj_student.number[9]>>obj_student.major[15];
    cout<<"请输入点名占的分数、点名次数和已到的次数。\n";
    cin>>obj_student.zhdfsh1>>obj_student.dmcsh>>obj_student.ddcsh;
    cout<<"请输入作业占的分数和作业情况。\n";
    cout<<"(作业情况等级为a~e,为100%~60%,一一对应。\n";
    cin>>obj_student.zhdfsh2>>obj_student.zyqk;
    cout<<"请输入期中考占的分数和考得的成绩。\n";
    cin>>obj_student.zhdfsh3>>obj_student.midmark;
    cout<<"请输入期末考占的分数和考得的成绩。\n";
    cin>>obj_student.zhdfsh4>>obj_student.fimark;
    totalmark=obj_student.total_mark(obj_student.att_mark,obj_student.home_mark,obj_student.mid_mark,obj_student.final_mark);
    cout<<"该学生最终成绩为:\n"<<totalmark<<endl;
}
2010-05-25 17:58
南国利剑
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:29
帖 子:1165
专家分:3536
注 册:2010-4-12
收藏
得分:7 
同意楼上。

提醒楼主,发代码最好加注释,并且尽量把出现的问题也详细说明一下。
否则别人要帮你也很不容易啊。

南国利剑
2010-05-26 02:40
hamdgem
Rank: 1
等 级:新手上路
帖 子:4
专家分:3
注 册:2010-4-18
收藏
得分:0 
还是有问题,我先改改……
2010-05-26 16:13
快速回复:各位大虾,问一下这代码有什么错误。
数据加载中...
 
   



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

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