北邮信通C++上机实验 第五章

2020-03-26 21:35

第五章实验题

一.基础题

1.

#include using namespace std; void f1(int x[10]) { }

void main() {

int a[10];

for (int i = 0; i <= 9; i++) for (int i = 0; i <= 9; i++) { }

x[i] = 2 * x[i] + 1;

if (i == 6)//到第六行的时候换行 { } else

cout << x[i] << \

cout << endl << x[i] << \

cin >> a[i];//从键盘读取a的值

f1(a);//从实际参数a到形式参数X的传递方式是地址传递,系统

为指针变量x在栈中分配空间 }

system(\

2.

#include using namespace std; inline int f1(int x, int y) { }

void main()

return x > y ? x : y;

{ }

int a = 120, b = 300, c = 40; int d, e, f; d = f1(a, b); e = f1(d, c);

cout << \cout << \cout << \

cout << \三个数中的最大值为\system(\

3.

#include

using namespace std; int sum(int a, int b)//函数定义 { }

double sum(double x, double y, double z)//重载函数定义 { }

float sum(float x, float y) { }

void main() {

cout << \调用函数sum(int,int)的结果为:\<< sum(13, 14) return x + y; return x + y + z; return a + b;

<< endl;//用Int型调用第一种函数

cout << \调用函数sum(double,double,double)的结果为:\

<< sum(1.32,1.14,1.018) << endl;//用double型实参调用第二种函数

cout << \调用函数sum(int,int)的结果为:\<<

sum(12.7f,34.78f) << endl;//用float型实参调用第三种函数

}

system(\

4.

#include using namespace std; int f1(int a); void main() {

int x = 5; static int y; y = y + f1(x);

cout << \y = y + f1(x);


北邮信通C++上机实验 第五章.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:尔雅通识课《国学智慧》作业考试答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: