文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 《c++程序设计》谭浩强_答案
侵权投诉

《c++程序设计》谭浩强_答案

C++

第一章 1.5题

#include <iostream> using namespace std; int main() {

cout<<"This"<<"is"; cout<<"a"<<"C++"; cout<<"program."; return 0; 1.6题

#include <iostream> using namespace std; int main() { int a,b,c; a=10; b=23; c=a+b; cout<<"a+b="; cout<<c; cout<<endl; return 0; } 1.7七题

#include <iostream> using namespace std; int main() { int a,b,c;

int f(int x,int y,int z); cin>>a>>b>>c; c=f(a,b,c); cout<<c<<endl; return 0; }

int f(int x,int y,int z) { int m; if (x<y) m=x; else m=y; if (z<m) m=z; return(m); } 1.8题

#include <iostream> using namespace std;

int main() { int a,b,c; cin>>a>>b; c=a+b;

cout<<"a+b="<<a+b<<endl; return 0; } 1.9题

#include <iostream> using namespace std; int main() { int a,b,c;

int add(int x,int y); cin>>a>>b; c=add(a,b);

cout<<"a+b="<<c<<endl; return 0; }

int add(int x,int y) {int z; z=x+y; return(z); } 2.3题

#include <iostream> using namespace std; int main() {char

c1='a',c2='b',c3='c',c4='\101',c5='\116';

cout<<c1<<c2<<c3<<'\n';

cout<<"\t\b"<<c4<<'\t'<<c5<<'\n'; return 0; } 2.4题

#include <iostream>

using namespace std; int main() {char

c1='C',c2='+',c3='+';

cout<<"I

say:

\""<<c1<<c2<<c3<<'\"'; cout<<"\t\t"<<"He says: \"C++ is

very

interesting!\""<< '\n';

return 0; } 2.7题

#include <iostream> using namespace std; int main() {int i,j,m,n; i=8; j=10; m=++i+j++; n=(++i)+(++j)+m;

cout<<i<<'\t'<<j<<'\t'<<m<<'\t'<<n<<endl; return 0; } 2.8题

#include <iostream> using namespace std; int main()

{char c1='C', c2='h', c3='i', c4='n', c5='a'; c1+=4; c2+=4; c3+=4; c4+=4; c5+=4;

cout<<"password is:"<<c1<<c2<<c3<<c4<<c5<<endl; return 0; } 3.2题

#include <iostream> #include <iomanip> using namespace std; int main ( )

{float h,r,l,s,sq,vq,vz; const float pi=3.1415926; cout<<"please enter

r,h:"; cin>>r>>h;

l=2*pi*r; s=r*r*pi; sq=4*pi*r*r; vq=3.0/4.0*pi*r*r*r; vz=pi*r*r*h;

cout<<setiosflags(ios::fixed)<<setiosflags(ios::right)

<<setprecision(2); cout<<"l=

"<<setw(10)<<l<<endl; cout<<"s=

"<<setw(10)<<s<<endl;

cout<<"sq="<<setw(10)<<sq<<endl;

cout<<"vq="<<setw(10)<<vq<<endl;

cout<<"vz="<<setw(10)<<vz<<endl; return 0; } 3.3题

#include <iostream> using namespace std; int main () {float c,f;

cout<<"请输入一个华氏温度:"; cin>>f;

c=(5.0/9.0)*(f-32); //注意5和9要用实型表示,否则5/9值为0

cout<<"摄氏温度为:"<<c<<endl; return 0; }; 3.4题

#include <iostream> using namespace std;

int main ( ) {char c1,c2;

cout<<"请输入两个字符c1,c2:";

c1=getchar(); //

第1页

热门文档

相关文档

  • 《c++程序设计》谭浩强_答案 第10章

    《c++程序设计》谭浩强_...1/2 相关文档推荐 第10章练习及答案 谭浩强......《c++程序设计》谭浩强_...

  • 《c++程序设计》谭浩强_答案

    《c++程序设计》谭浩强_答案 隐藏>> 第一章 1.5 题 #include <iostream> using namespace std; int main() { cout<<"This"<<"is"; cout<<"a"<<"C++...

  • 《c++程序设计》谭浩强_答案

    《c++程序设计》谭浩强_答案 隐藏>> CCCCDFDSFFVGCCC C++程序设计课后答案 袁俊南 袁俊南 第一章 1.5 题 #include <iostream> using namespace std; int main(...

  • 《c++程序设计》谭浩强_答案

    《c++程序设计》谭浩强_答案_电脑基础知识_IT/计算机_专业资料 暂无评价0人阅读0次下载举报文档 《c++程序设计》谭浩强_答案_电脑基础知识_IT/计算机_专业...

  • 《c++程序设计》谭浩强课后习题答案

    《c++程序设计》谭浩强课后习题答案_工学_高等教育_教育专区。c++程序设计谭浩强课后习题答案。第一章 1.5题 #include <iostream> using namespace std; int main...

  • 《c++程序设计》谭浩强_答案

    《c++程序设计》谭浩强_答案 C++C++隐藏>> 第一章 1.5 题 #include <iostream> using namespace std; int main() { cout<<"This"<<"is"; cout<<"a"...

  • 《c++程序设计》谭浩强 答案_第06章

    谭浩强C程序设计(第三版答... 54页 5财富值 c程序设计(第三版)答案_谭... 20页 免费喜欢此文档的还喜欢 谭浩强《C++程序设计》课件... 100页 免费 《...

  • 《c++程序设计》谭浩强课后习题答案

    《c++程序设计》谭浩强课后习题答案_理学_高等教育_教育专区 暂无评价0人阅读0次下载举报文档 《c++程序设计》谭浩强课后习题答案_理学_高等教育_教育专区。第...

  • 《c++程序设计》谭浩强 答案_第05章

    《c++程序设计》谭浩强 答案_第05章 一共有14章一共有14章隐藏>> 5.1 题 #include <iostream> #include <iomanip> using namespace std; #include <math....

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email