- 33
- 0
- 约5.43万字
- 约 57页
- 2016-10-12 发布于贵州
- 举报
c面向对象设计课后习题答案(谭浩强版)
第一章
5:
#include iostream
using namespace std;
int main()
{
coutThisis;
coutaC++;
coutprogram.endl;
return 0;
}
6:
#include iostream
using namespace std;
int main()
{
int a,b,c;
a=10;
b=23;
c=a+b;
couta+b=;
coutc;
coutendl;
return 0;
}
7:
#include iostream
using namespace std;
int main()
{
int a,b,c;
int f(int x,int y,int z);
cinabc;
c=f(a,b,c);
coutcendl;
return 0;
}
int f(int x,int y,int z)
{
int m;
if (xy) m=x;
else m=y;
if (zm) m=z;
return(m);
}
8: #include iostream
using namespace std;
int main()
{
int a,b,c;
cinab;
c=a+b;
couta+b=a+bendl;
return 0;
}
9:
#include iostream
using namespace std;
int main()
{int add(int x,int y);
int a,b,c;
cinab;
c=add(a,b);
couta+b=cendl;
return 0;
}
int add(int x,int y)
{int c;
c=x+y;
return(c);
}
10:
#include iostream
using namespace std;
int main()
{void sort(int x,int y,int z);
int x,y,z;
cinxyz;
sort(x,y,z);
return 0;
}
void sort(int x, int y, int z)
{
int temp;
if (xy) {temp=x;x=y;y=temp;} //{ }内3个语句的作用是将x和y的值互换)
if (zx) coutz,x,yendl;
else if (zy) coutx,z,yendl;
else coutx,y,zendl;
}
11:
#include iostream
using namespace std;
int main()
{int max(int a,int b,int c=0);
int a,b,c;
cinabc;
coutmax(a,b,c)=max(a,b,c)endl;
coutmax(a,b)=max(a,b)endl;
return 0;
}
int max(int a,int b,int c)
{if(ba) a=b;
if(ca) a=c;
return a;
}
12:
#include iostream
using namespace std;
int main()
{
void change(int ,int );
int a,b;
cinab;
if(ab) change(a,b);
coutmax=a min=bendl;
return 0;
}
void change(int ,int )
{
int r1,r2,temp;
temp=r1;
r1=r2;
r2=temp;
}
13:
#include iostream
using namespace std;
int main()
{void sort(int ,int ,int );
int a,b,c,a1,b1,c1;
coutPlease enter 3 integers:;
cinabc;
a1=a;b1=b;c1=c;
sort(a1,b1,c1);
couta b c in sorted order is ;
couta1 b1 c1endl;
return 0;
}
void sort(int i,int j,int k)
{ void change(int ,int );
if (ij) change(i,j);
if (ik) change(i,k);
if (jk) change(j,k);
}
void
您可能关注的文档
- Autocad14中文版安装激活图文教程.doc
- AutoCAD15建筑设计视频教程.doc
- AutoCAD14安装教程附注册机.doc
- AUTOCAD15【cad2015】中文版安装教程.docx
- Autocad16 安装图文教程.doc
- Autocad使用教程及激活码安装教程.docx
- AutoCAD命令详细讲解与技巧(基础教程).doc
- AUTOCAD员习题集.doc
- AutoCAD建模教程.doc
- AutoCAD开发初级入门教程.docx
- 2026年预防为主,生命至上安全培训课件.pptx
- 2026年三级安全教育.pptx
- 2026年检测业务安全培训.pptx
- 2026年消防动火培训.pptx
- 2026年重大事故隐患专项排查整治行动清单.pdf
- 2026年健康义普急救.pptx
- 2025—2026学年度四川省广元市苍溪县九年级上学期期末考试历史试题(含答案).docx
- 2025—2026学年度四川省泸州市合江县马街中学校九年级上学期期末历史试题(含答案)(九上_九下第二单元).docx
- 2025—2026学年度云南省曲靖市宣威市民族中学等校联考九年级上学期期末模拟历史试题(含答案).docx
- 2025-2026学年科普版七年级下册英语Unit7 Being a Smart Shopper素养测评卷(含答案).docx
最近下载
- 银行客户经理财富管理业务操作手册.docx VIP
- 广美附中2024年数学试卷.pdf
- 非处方药目录(全集).doc
- 注册会计师-税法-基础练习题-第六章城市维护建设税法和烟叶税法-第三节教育费附加和地方教育附加.docx VIP
- 俄语视听说基础教程3全套课件.pptx
- 2025年《可爱的中国》新疆地方教材(小学版)教案范文.docx VIP
- 常州大学《数据结构与算法分析》2022-2023学年期末试卷.doc VIP
- 常州大学《数据结构》2021-2022学年期末试卷.doc VIP
- 常州大学《数据结构与算法分析》2021-2022学年期末试卷.doc VIP
- 注册会计师-税法-基础练习题-第六章城市维护建设税法和烟叶税法-第二节烟叶税法.pdf VIP
原创力文档

文档评论(0)