题目内容

下列程序的输出结果如下:x, y=10,26x, y=26,10x, y=9,27请将程序填充完整#include < iostream>using namespace std;void f2((1)________){ int z = x; x = y; y = z;}void main(){ int x = 10, y = 26; cout << "x, y=" << x << "," << y << endl; f2(x,y); cout << "x, y=" << x << "," << y << endl; x++; y--; f2(x,y); cout << "x, y=" << x << "," << y << endl;}

查看答案
更多问题

阅读下列程序,并写出输出结果。#includeusing namespace std;int f(int);void main(){ int i; for (i = 0; i<3; i++)cout << f(i) << ","; cout << endl;}int f(int a){ int b = 0; static int c = 3; b++; c++; return(a + b + c);}

阅读下列程序,并写出输出结果。#includeusing namespace std;int min(int a,int b){ return a

写出下面程序执行后的运行结果。#include< iostream>using namespace std;#define DEBUGvoid main(){ int a = 20, b =10, c; c = a / b;#ifdef DEBUG cout << a << "/" << b << "=";#endif cout << c;}

例3-2 数制转换输入一个8位二进制数,将其转换为十进制数输出。例如:从键盘输入110111012=1×23+1×22+0×21+1×20=1310所以,程序应输出13源代码:#include using namespace std;double power (double x, int n); //计算x的n次方int main() { int value = 0; cout << "Enter an 8 bit binary number "; for (int i = 7; i >= 0; i--) { char ch; cin >> ch; if (ch == '1') value += static_cast(power(2, i)); } cout << "Decimal value is " << value << endl; return 0;}double power (double x, int n) { double val = 1.0; while (n--) val *= x; return val;}试问:1、运行结果输入01101000,则power函数执行( )次?2、如果输入00111110,power函数又执行( )次?

答案查题题库