- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
C 面向对象程序设计答案章谭浩强.doc
第一章
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 change(int x,int y)
您可能关注的文档
最近下载
- 北师大版-数学-五年级上册-《多边形的面积》单元分析.doc VIP
- 新高考背景下历史课程教学改革探索教学研究课题报告.docx
- 2023-2024学年四川省成都市锦江区八年级(下)期末数学试卷(1).doc VIP
- DL T 1144-2012《火电工程项目质量管理规程》.pdf VIP
- 教科版六年级科学上册全册必背知识点知识清单.pdf VIP
- 《孩子是春天的另一种姿势》阅读练习及答案.doc VIP
- 2022-2023学年四川省成都市锦江区八年级(上)期末数学试卷.docx VIP
- T_CVMA 224-2025 猫传染性腹膜炎诊断规程.pdf VIP
- T_CVMA 232-2025 猪星状病毒五型荧光PCR检测方法.docx VIP
- T_CVMA 252-2025 马四肢X线及超声操作规范.pdf VIP
文档评论(0)