第一范文网 - 专业文章范例文档资料分享平台

习题1

来源:用户分享 时间:2025/5/29 11:51:36 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

t1.showtime(); t2.settime(12,34); t2.showtime(); t3.settime(12); t3.showtime(); t4.settime(); t4.showtime(); return 0; }

4、

#include using namespace std; class ADD { public:

int add(int xx,int yy); float add(float xx,float yy);

double add(double xx,double yy); void print(int z); void print(float z); void print(double z); private: int x1,y1,z1; float x2,y2,z2; double x3,y3,z3; };

int ADD::add(int xx,int yy) { x1=xx; y1=yy;

21

z1=x1+y1; return z1; }

float ADD::add(float xx,float yy) { x2=xx; y2=yy; z2=x2+y2; return z2; }

double ADD::add(double xx,double yy) { x3=xx; y3=yy; z3=x3+y3; return z3; }

void ADD:: print(int z) {

cout<< x1<<'\\t'<< y1<<'\\t'<< z<

void ADD:: print(float z) {

cout<< x2<<'\\t'<< y2<<'\\t'<< z<

void ADD:: print(double z) {

cout<< x3<<'\\t'<< y3<<'\\t'<< z<

22

{

int m1; float m2; double m3; ADD a1,a2,a3;

cout<<\请输入两个整型数:\ int d1,d2; cin>>d1>>d2; m1=a1.add(d1,d2);

cout<<\ y z\ a1.print(m1);

cout<<\请输入两个单精度实型数:\ float b1,b2; cin>>b1>>b2; m2=a2.add(b1,b2);

cout<<\ y z\ a2.print(m2);

cout<<\请输入两个双精度实型数:\ double c1,c2; cin>>c1>>c2; m3=a3.add(c1,c2);

cout<<\ y z\ a3.print(m3); return 0; }

5、

#include class Student {

int english,computer,total; public:

void getscore();

23

void display(); void sort(Student*); ~Student(); };

void Student::getscore() {

cout<<\输入数学成绩:\ cin>>english;

cout<<\输入语文成绩:\ cin>>computer; total=english+computer; }

void Student::display() {

cout<<\数学=\语文=\总分=\}

void main() {

Student *A[5],*tmp; int i,n=5;

for (int j=0;jgetscore();

}

for(j=0;j

tmp=A[i];A[i]=A[i+1]=tmp;

24

}

cout<

for(i=0;i

A[i]->display();

25

搜索更多关于: 习题1 的文档
习题1.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c0tsbk9nz0t2wkqq4m2mx_6.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top