第五章实验题
一.基础题
1.
#include
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
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
int x = 5; static int y; y = y + f1(x);
cout << \y = y + f1(x);