有如下程序: #include<iostream> using namespaee std; int main { void function(double val); double val: function(val); eout<<val: return 0; } void function(double val) { val=3; } 编译运行这个程序将出现的情况是( )。
A.编译出错,无法运行
B.输出:3
C.输出:3.0
D.输出一个不确定的数
第1题:
有如下程序: #include <iostream> void fun (int& x,int y){int t=x;x=y;y=t;} int main() { int a[2]={23,42}; fun (a[1],a[0]; std::cout<<a[0]<<”,”<<a[1]<<std:: ond1; retum0; }执行后的输出结果是______ 。
A.41,41
B.23,23
C.13,42
D.42,23
第2题:
如下程序的输出结果是 #include<iostream> void fun(int & X,inty){intt=x;x=y;y=t;} int main( ){ int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; }
A.42,42
B.23,23
C.23,42
D.42,23
第3题:
使用VC++6.0打开考生文件夹下的源程序文件1.cpp,该程序运行时有错误,请改正错误,使得程序输出: Hello test 注意:不要改动main函数,不能增加或删除行,也不能更改程序的结构,错误的语句在 //******error******的下面。 试题程序: include<iostream> //********error******** template<T> voidfun(Tt) { std::cout<<"test"<<std::endl; } //********error******** template<bool> voidfun(boolt) { std::cout<<(t?"Hell0":"Hi")<<std::endl; } intmain { //********error******** boolflag=TRUE; fun(flag); fun((int)flag); return0; }
第4题:
第5题:
有如下程序: #include <stdio.h> main() { int x=23; do { Printf("%d",x--);} while(! x); } 该程序的执行结果是( )。
A.321
B.23
C.不输出任何内容
D.陷入死循环
第6题:
有如下程序: #include <iostream> void fun(int& x, int y){int t=x;x=y;y=t;} int main () { int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; } 执行后的输出结果是
A.42,42
B.23,23
C.23,42
D.42,23
第7题:
对于下面程序,对p进行赋值正确的是( )。 class A{ public:fun(int i){cout<<i<<endl;} }; main(){ void(A::*p)(int); }
A.p=fun;
B.p=fun();
C.p=A::fun;
D.p=A::fun()
第8题:
有如下程序: #include<iostream> void fun(int&x, int y){int t=x; x=y; y=t;} int main() { int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::end1; return 0; } 执行后的输出结果是( )。
A.42,42
B.23,23
C.23,42
D.42,23
第9题:
有以下程序: #include <stdlib.h> void fun(int * s,int * * d) { * *d=*(s+2); } main() { int a[]={1,2,3,4,5},*b; b=(int *)malloc(sizeof(int)); fun(a,&B) ; printf("%d\n",*b+1); } 程序的输出结果是( )
A.2
B.3
C.4
D.5
第10题:
Main()函数可以有返 回值(int),也可以为void