更多"[单选题]有如下程序:#include <iostream>"的相关试题:
[单选题]有如下程序:
#include
Using namespace std;
Void function2(int n);
Void function1(int n){
if(n<=0) return;
function2(n-2);
}
Void function2(int n){
if(n<=0) return;
function1(n-1);
}
Int main){
function1(5);
return 0;
}
下列关于程序运行情况的描述中,正确的是( )。
A. function1运行1次,function2运行2次
B. function1运行2次,function2运行1次
C. function1运行2次,function2运行3次
D. function1运行2次,function2运行2次
[单选题]有如下程序:
#include
using namespace std;
class Base{
protected:
Base(){cout<<'A';}
Base(char c){cout<A.B
B.BA
C.AB
D.BB
[单选题]有如下程序:
#include
#include
Using namespace std;
Int main() {
int i,n;
for(i=0;i<8;i++)
{ n=rand()%5; //rand()为伪随机函数,可产生任意正整数
switch(n)
{ case 1:
case 3: cout << n << endl; break;
case 2:
case 4: cout << n << endl; continue;
case 0: exit(0); //exit()为终止程序函数
}
cout << n << endl;
}
return 0;
}
以下有关程序执行情况的叙述,正确的是( )。
A. for循环语句固定执行8次
B. 当产生的随机数n为4时结束循环
C. 当产生的随机数n为1和2不做任何操作
D. 当产生的随机数n为0时结束程序运行
[单选题]有如下程序段:
Int i=5;
While( int i=0 ){ cout << '*'; i--; }
执行时输出"*"的个数是( )。
A. 0
B. 1
C. 5
D. 无穷
[单选题]有以下程序
#include
Using namespace std;
Int main(){
int a;
cin >> a;
if(a++<9) cout << a;
else cout << a--;
return 0;
}
程序运行时从键盘输入9 回车,则输出结果是( )。
A. 10
B. 11
C. 9
D. 8
[单选题]如下程序执行结果是( )
#include
Void main()
{ int x=23;
Do
{ printf("%d",x--);
}while(!x);
}
A. 321
B. 23
C. 不输出任何内容
D. 陷入死循环
[单选题]下列程序的运行结果是:( )
#include
using namespace std;
int main()
{
int a=2;
int b=a+1;
cout<A.0.66667
B.0
C.0.7
D.0.6666666…
[单选题]如下程序的执行结果是( )
#include
Void main( )
{ int i,sum=0;
For(i=1;i<=3;sum++) sum+=i;
Printf("%d\n",sum);
}
A. 6
B. 3
C. 死循环
D. 0
[单选题]运行如下程序,输出结果是( )。
#include
Using namespace std;
Int main(){
int a=2,b=-1,c=2;
if(a if(b<0) c=0;
else c+=1;
cout << c << endl;
return 0;
}
A. 0
B. 1
C. 2
D. 3
[单选题]运行如下程序,输出结果为( )。
#include
Using namespace std;
Int main() {
int x=1,y=0;
if(!x) y++;
else if(x==0)
if(x) y+=2;
else y+=3;
cout << y << endl;
return 0;
}
A. 3
B. 2
C. 1
D. 0
[单选题]有如下程序:
Int x = 3;
Do {
x -= 2;
cout << x;
} while( !(--x) );
执行这个程序的输出结果是( )。
A. 1
B. 30
C. 1-2
D. 死循环
[简答题]以下程序的运行结果为 )。
#include
Using namespace std;
Int a{5};
Int main()
{
{
int a{2};
cout << ::a;
cout << a;
}
cout << a << endl;
return 0;
}
[单选题]以下程序的输出结果是( )。
#include
Using namespace std;
Int main() {
int a=0, i;
for (i=0;i<5;i++)
{
switch (i)
{
case 0:
case 3:a+=2;break;
case 1:
case 2:a+=3;
default:a+=5;
}
}
cout << a < return 0;
}
A. 10
B. 20
C. 25
D. 30
[单选题]以下程序的运行结果是( )。
#include
Using namespace std;
Int main()
{
int x=1;
switch(x)
{ case 1:++x;
case 0:--x;
default: x+=7;
}
cout << x << endl;
return 0;
}
A. 2
B. 1
C. 7
D. 8