以下程序的输出结果是( )。#include using namespace std;int fun( ){ static int s=0; s+=1; return s; }int main(){ char str[]="abcdef"; int n, i=0; while(str[i]!='\0') { n=fun(); i++; } cout<
查看答案
以下程序的输出结果是( )。 #include using namespace std;long fib(int n){ if(n>2) return(fib(n-1)+fib(n-2)); else return(1);}int main() { cout<
A. 1
B. 2
C. 4
D. 5
下列程序如果输入an anple,该程序的输出结果是( )。#include #includeusing namespace std;void inverse(char str[ ]){ char t; int i, j; for(i=0, j=strlen(str);i>str; inverse(str); cout<
A. an anple
B. elpna na
C. an
D. na
下列程序的运行结果是( )。 #include using namespace std;int *sum( int n ){ int s=0; for (int i=1; i<=n; i++) s+=i; return &s;}int main( ){ int n=9, *total; total=sum(n); cout<
A. 9
B. 10
C. 45
D. 55
要求函数的功能是交换x和y中的值,且通过正确调用返回交换结果。能正确表示此功能的函数是( )。
A. void funa(int *x, int *y) { int *p; *p = *x; *x = *y, *y = *p; }
B. void funb(int x, int y) { int t; t = x; x = y; y = t; }
C. void func(int *x, int *y) { *x = *y; *y = *x; }
D. { *x = *x + *y; *y = *x - *y; *x = *x - *y; }