C++程序设计(第二版)谭浩强----程序题课后习题答案第二章

2018-03-02 08:28:37来源:cnblogs.com作者:浅安时光‘’人点击

分享

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;
}

结果:

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;
}

结果:

 5.

(1). -72.5;

(2). 11.5;

(3). 23;

(4). a = b = c = 9;

(5). a = b = 6;

(6). a = 6, b = 5;

(7). 2.5;

(8). 3 or 3.5;

6.

a = 12;

a += a; 24

a -= 3; 9

a *=2 + 3; 60a /=a + a; 0a %=(n%=2); 0a += a -= a *= a; 0 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;
}

结果:

8.

#include<iostream>
using namespace std;
int main()
{
char c1 = 'C', c2 = 'h', c3 = 'i', c4 = 'n', c5 = 'a';
int n = 4;
c1 = c1 + n;
c2 = c2 + n;
c3 = c3 + n;
c4 = c4 + n;
c5 = c5 + n;
cout << c1 << c2 << c3 << c4 << c5 << endl;
return 0;
}

结果:

相关文章

    无相关信息

最新文章

123

最新摄影

闪念基因

微信扫一扫

第七城市微信公众平台