更多"[单选题]有如下程序:#include <iostream>"的相关试题:
[单选题]有如下程序:
#include
using namespace std;
class Base{
protected:
Base(){cout<<'A';}
Base(char c){cout<A.B
B.BA
C.AB
D.BB
[单选题]有如下程序:
#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
Void main()
{ int x=23;
Do
{ printf("%d",x--);
}while(!x);
}
A. 321
B. 23
C. 不输出任何内容
D. 陷入死循环
[单选题]如下程序的执行结果是( )
#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 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
[单选题]运行如下程序,输出结果是( )。
#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 =10;
do {
cout << --x ;
}while( !x );
return 0;
}
[单选题]有以下程序
#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 "
#include
Using namespace std;
Int main()
{ char a[30]="nice to meet you!";
strcpy(a+strlen(a)/2,"you");
cout << a;
return 0;
}
A. nice to meet you you
B. nice to
C. meet you you
D. nice to you
[单选题]有以下程序段
#include
main()
{ …
while( getchar()!='\n');
…
}
以下叙述中正确的是( )。
A.此while语句将无限循环
B.getchar()不可以出现在while语句的条件表达式中
C.当执行此while语句时,只有按回车键程序才能继续执行
D.当执行此while语句时,按任意键程序就能继续执行
[单选题]下列程序的运行结果是:( )
#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
Int i=0;
Void fun()
{
{
static int i=1;
std::cout< }
std::cout<}
Int main()
{
fun(); fun();
return 0;
}
程序执行后的输出结果是( )。
A. 1,2,1,2,
B. 1,2,2,3,
C. 2,0,3,0,
D. 1,0,2,0,
[单选题] 有以下程序
#include
#define N 20
Void fun(int a[],int n,int m)
{ int i ;
for(i=m;i>=n;i--)
{
A[i+1]=a[i];
}
Int main()
{ int i,a[N]={1,2,3,4,5,6,7,8,9,10};
fun(a,2,9);
for(i=0;i<5;i++)
{
Printf("%d",a[i]);
}
return 0;}
程序运行后的输出结果是( )。
A.10234
B.12344
C.12334
D.12234