若运行时给变量x输入12,则以下程序的运行结果是#include <iostream.h>void main(){ int x,y; cin

题目
若运行时给变量x输入12,则以下程序的运行结果是include void main(){ int x,y; cin

若运行时给变量x输入12,则以下程序的运行结果是 #include <iostream.h> void main() { int x,y; cin>>x; y=x>12? x+10:x-12; cout<<y; cout<<endl; }

A.0

B.22

C.12

D.10

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

下面程序的运行结果是includevoid fun(int * a,int * b){ int x= * a; * a = * b;*

下面程序的运行结果是 #include<iostream.h> void fun(int * a,int * b) { int x= * a; * a = * b; * b=x; cout <<*a<< *b<<""; } void main( 0 { int x =1,y =2; fun(&x,&y); cout<< x << y <<end1; }

A.12 12

B.12 21

C.21 12

D.21 21


正确答案:D
解析:本题考查的是指针和引用,函数 fun完成把x和y互换的操作。

第2题:

若运行时给变量x输入12,则以下程序的运行结果是

main()

{int x,y;

scanf("%d",&x);

y=x>12?x+10:x-12;

printf("%d\n",y);

}

A.0

B.22

C.12

D.10


正确答案:A

第3题:

阅读下面程序: include void fun(int n) { int x(5); static int y(10); if(n>0) {

阅读下面程序:

include<iostream.h>

void fun(int n)

{

int x(5);

static int y(10);

if(n>0)

{

++x;

++y;

cout<<x<<","<<y<<end1;

}

}

void main()

{

int m(1);

fun(m);

}

则该程序的输出结果是______。


正确答案:611
6,11

第4题:

以下程序的执行结果是______。 include void main() { int x=5 y=2; cout<

以下程序的执行结果是______。

include<iostream.h>

void main()

{

int x=5 y=2;

cout<<! (y==x/2)<<",";

cout<<(y!=x%3)<<",";

cout<<(x>0 && y<0=<<",";

cout<<(x!=y||x>=y)<<endl;

}


正确答案:0001
0,0,0,1

第5题:

假如输入为30和60,下列程序运行的结果是【】。 include void main() { int a, b; cin>>

假如输入为30和60,下列程序运行的结果是【 】。

include<iostream.h>

void main() {

int a, b;

cin>>a>>b;

if(a<b) {

a=a+b;

b=a-b;

a=a-b;

}

cout<<a<<“,”<<b<<endl

}


正确答案:60 30
60 30

第6题:

下面程序的运行结果是 include void fun(int * a,int * b) { int x= * a; * a= *

下面程序的运行结果是

#include<iostream.h>

void fun(int * a,int * b)

{

int x= * a;

* a= * b; * b=X;

cout < < * a < < * b < <" ";

}

void main( )

{

int x=1,y=2;

fun(&x,&y) ;

cout < < X < < y < < endl;

}

A.12 12

B.12 21

C.21 12

D.21 21


正确答案:D
解析:本题考查的是指针和引用,函数 fun完成把x和y互换的操作。

第7题:

阅读以下程序 include void main( ) { char line[10]; cin>>line; cout<

阅读以下程序

#include<iostream.h>

void main( )

{

char line[10];

cin>>line;

cout<<line<<endl;

}

如运行时输入This is example.<CR>,则程序的输出结果是

A.This

B.This is

C.This is a

D.This is an example.


正确答案:A
解析:本题考察C++中cin输入流对象的使用规则,其特点是以空格、回车和tab为分隔符。因此this和is之间的空格告诉cin对象停止接收后面的数据。故正确答案为A。

第8题:

阅读下面程序: include void f(int n) { int x(5); static int y(10); if(n>0) { ++

阅读下面程序:

include<iostream.h>

void f(int n)

{

int x(5);

static int y(10);

if(n>0)

{

++x;

++y;

cout<<x<<","<<y<<endl;

}

}

void main()

{

int m(1);

f(m),

}

则该程序的输出结果是【 】


正确答案:611
6,11

第9题:

以下程序运行后的输出结果是【】。 include void fun(int x,int y) {x=x+y;y=x-y

以下程序运行后的输出结果是【 】。

include<iostream.h>

void fun(int x,int y)

{ x=x+y;y=x-y;x=x-y;

cout<< x << "," <<y << " ,";}

void main( )

{ int x=2,y=3;fun(x,y);

cout<< x << "," << y << endl;}


正确答案:3223
3,2,2,3 解析:main函数和fun函数中的变量x和y都是局部变量,它们各自独立,在本题 fun函数中:接入实参的值传递:x=2,y=3,执行:x=x+y后,x=5,y=3,执行:x=x-y后,x=5,y=3,执行:y=x-y后,x=3,y=2。所以,第一次执行cout显示结果是3和2返回到main函数中,输出main函数中的x和y的值2,3。

第10题:

以下程序的运行结果是()。includevoid sub(int x,int y,int*z){*Z=y-x;}void main()

以下程序的运行结果是( )。 #include<iostream.h> void sub(int x,int y,int*z) {*Z=y-x;} void main() {int a,b,c; sub(10,5,&a); sub(7,a,&b); sub(a,b,&c); cout<<a<<“,”<<b<<“,”<<c<<endl;}

A.5,2,3

B.-5,-12,-7

C.-5,-12,-17

D.5,-2,-7


正确答案:B
解析: 在C++语言中,调用函数不可能改变实参指针变量的值,但可以改变实参指针变量所指变量的值。

更多相关问题