哪位高手来帮我做下C++的题目啊?跪求了!!!

来源:百度知道 编辑:UC知道 时间:2024/05/18 08:15:03
1. cout << ( 8*5*2+3 ) / 2+4;
2. 31 % 7 +2
3. int x = 3;
while ( x <= 6 ) {
x++;
cout << “x 的值是: “ << x << endl;
}
cout << “x 最终的值是: “ << x << endl;
4. for ( int i = 1; i<=6; i++ ) {
switch (i) {
case 1:
cout << “x 的值是1\n”; break;
case 4:
cout << “x 的值是4\n”;
case 6:
cout << “x 的值是6\n”; break;
default:
cout << “x 的值不是1,4 也不是6\n”;
}
}
5. void f1() void f2( int x )
{ int x = 5; { x += 10;
f2(x); cout << x << endl;
cout << x << endl; }
}
在调用函数f1时,程序段的输出结果是什么?

三、改错题:(直接改在出错的位值上)

1. int fstPlace = 6
fstPlace = 6;
2. int q = 0;
if ( q = 0 )
cout << “q 等于 0”;
3. int x = 9, y = 3;
if ( x =! y )
cout << “不相等”
4. if (

1. 45
2. 5
3. 4
5
6
7
7
4. x的值是1
x的值不是1,4也不是6
x的值不是1,4也不是6
x的值是4
x的值不是1,4也不是6
x的值是6
5. 15
15

1. int fstPlace = 6 //缺少冒号
fstPlace = 6;
2. int q = 0;
if ( q = 0 ) //符号应为“==”
cout << “q 等于 0”;
3. int x = 9, y = 3;
if ( x =! y ) //不等号应为“!=”
cout << “不相等”
4. if ( grade >= 60 )
cout << “通过\n” ;
else //else部分应包括后面两句,采用{}
cout << “没通过\n”
cout << “你必须重修!”
5. int maximum(int x, int y, int z );
{
int max = x;
if ( y > max )
max = y;
if ( z > max ) //添加else
max = z;
return max;
}
6. int array[ 10 ] = { 0 };
for ( int i = 0; i<= 10; i++ ) //不能包含array[10]
cout << array[ i ];
7. const int arraySize = 5;
int a[arraySize];
arraySize =