游客:  注册 | 登录 | 搜索 | 帮助
3s地带



标题: VC编程题
HiiI
强风
Rank: 3



UID 5159
精华 0
积分 93
帖子 23
现金 83
贡献值 0
阅读权限 30
注册 2007-8-24
VC编程题
定义一个描述学生基本情况的类,数据成员包括姓名,学号,C++,英语和数学成绩,成员包括输出数据、置姓名和学号,置3门课的成绩,求出总成绩和平均成绩

顶部
frfixi
强风
Rank: 3



UID 3844
精华 0
积分 52
帖子 10
现金 42
贡献值 0
阅读权限 30
注册 2007-8-24
#include "iostream"
using namespace std;

class Student
{
private:
char name[10];
char id[20];
float C_result;
float Eng_result;
float Math_result;
public:
void show_info() //输出数据
{
cout<<name<<":"<<id<<" C++:"<<C_result<<" Eng:"<<Eng_result<<" Math:"<<Math_result<<endl;
}
void input_info()//置姓名和学号
{
cout<<"输入姓名:";
cin>>name;
cout<<"输入学号:";
cin>>id;
}
void input_result()//置3门课的成绩
{
cout<<"输入C++成绩:";
cin>>C_result;
cout<<"输入英语成绩:";
cin>>Eng_result;
cout<<"输入数学成绩:";
cin>>Math_result;
}
void input_result( float a, float b,float c)//用参数置3门课的成绩
{
C_result=a;
Eng_result=b;
Math_result=c;


}
float get_cout()//求出总成绩

{
return (C_result+Eng_result+Math_result);
}

float get_avrg()//取得平均成绩
{
return (C_result+Eng_result+Math_result)/3.0;
}
};

  
顶部


 
当前时区 GMT+8, 现在时间是 2008-12-2 11:56 清除 Cookies - 联系我们 - 3S地带 - Archiver - WAP - 赣ICP备07006302号
Powered by Discuz! 5.5.0  © Processed in 0.027037 second(s), 6 queries , Gzip enabled