以下程序的输出结果是()。 #include
第1题:
以下程序执行后输出的结果是【 】。
include<iostream>
include<fstream>
using namespace std;
int main(){
ofstream ofile("D:\\temp.txt");
if(!ofile){
cout<<"temp.txt cannot open"<<endl;
return 0;
}
ofile<<"This is a book" <<" " <<54321<<endl;
ofile.close();
ifstream ifile("D:\\temp.txt");
if(!ifile){
cout<<"temp.txt cannot open" <<endl;
return 0;
}
charstr[40];
ifile >> str;
ifile.close();
cout<<Str<<endl;
return 1;
}
第2题:
程序的输出结果是【 】。
include <iostream>
using namespace std;
class A{
int x;
public:
A(int x=1):x(x){cout<<x;}
};
void main(){
A a,b(2),c(3);
}
第3题:
下列程序的输出结果是【 】。
inClude<iostream>
rsing namespace std;
template<typename T>
T fun(Ta,Tb){retum(a<=b)?a:b;)
int main()
{
cout<<fun(3,6)<<','<<fun(3.14F,6.28F)<<endl; .
return 0;
}
第4题:
下列程序的输出结果是【 】。
include <iostream>
using namespace std;
int main()
{
int data=1;
int &r = data;
data+=5;
r+=5;
cout<<data<<end 1;
return 0;
}
第5题:
以下程序的输出结果是【 】。
include<iostream>
using namespace std;
int main(){
int sum,i;
for(sum=0,i=1;i<5;i++)sum+=i;
cout<<sum<<endl;
return 0;
}
第6题:
下面程序运行输出的结果是【 】。
include <iostream>
using namespace std;
int main(){
char a[]="Chinese";
a[3]='\0';
cout<<a<<endl;
return 0;
}
第7题:
下面程序的执行结果是【 】。
include<iostream>
include<iomanip>
using namespace std;
void main()
{
cout<<setfill('x')<<setw(10);
cout<<"Hello"<<endl;
}
第8题:
若有以下程序:
include <iostream>
using namespace std;
int main()
{
char str[10];
cin>>str;
cout<< str<<end1;
return 0;
}
当输入为:
This is a program!
那么执行程序后的输出结果是【 】。
第9题:
下列程序的输出结果是【 】
include<iostream>
using namespace std;
int &qetVar(int *pint)
{
renurn *pint;
}
int main ()
{
int a =10;
getVar(&a) = 20;
cout<<a<<end1;
return 0; }
第10题:
若有以下程序:
include <iostream>
using namespace std;
class Sample
{
private:
const int n;
public:
Sample(int i) :n(i) {)
void print()
{
cout<<"n="<<n<<end1;
}
};
int main()
{
sample a(10);
a.print();
return 0;
}
上述程序运行后的输出结果是【 】。
第11题:
有以下程序: #include<iostream> #include<string> using namespace std; int main() { char arr[2][4]; strcpy(arr[0],"you"); strcpy(arr[1],"me"); arr[0][3]='&'; cout<<arr[0]<<end1; return 0; } 执行后的输出结果是( )。
A.you&me
B.you
C.me
D.err
第12题:
有以下程序: #include <iostream> #include <string> usxng namespace std; int main() { char p[] = "abcdefgh"; cout<<strlen(strcpy(p,"12345"))<<end1; return 0; } 执行后输出的结果是( )。
A.8
B.12
C.5
D.7
第13题:
若有以下程序段:
include <iostream>
using namespace std;
int main()
{
char*p="abcdefgh",*r;
long*q;
q=(long*)p;q++;
r=(char*)q;
cout<<r<<end1;
return 0;
}
该程序的输出结果是【 】。
第14题:
以下程序的输出结果是 #include<iostream> using nameSpace std; int main() { cout.fill('*'); cout.width(5); cout<<hex<<100<<end1; return 0; }
A.**100
B.***64
C.100**
D.64***
第15题:
以下程序的输出结果是【 】。
include <iostream>
using namespace std;
void fun()
{
static int a=0;
a+=2;
cout<<a;
}
int main()
{
int CC;
for(CC=1;cc<4;CC++)
fun();
cout<<end1;
return 0;
}
第16题:
有以下程序:
include <iostream>
using namespace std;
int main()
{
int i=010,j=10;
cout<<(++i)<<","<<i--<<end1;
return 0;
}
则该程序运行后的输出结果是【 】。
第17题:
下列程序的输出结果是______。
include<iostream>
using namespace std;
void fun(int &rf)
{
rf*=2;
}
int main()
{
int num=500;
fun(num);
cout<<num<<endl;
return 0;
}
第18题:
下列程序的输出结果是______。
include<iostream>
using namespace std;
int main()
{
int data=l;
int &r = data;
data+=5;
r+=5;
cout<<data<<endl;
return 0;
}
第19题:
有以下程序,其输出结果是( )。 #include <iostream> using namespace std; int main(){ char a[10]={'1','2','3','4','5','6','7','8','9',0},*p; int i=8; p=a+i; cout<<p-3<<endl; return 0; }
A.6789
B.6
C.789
D.'6'
第20题:
下列程序输出结果是【 】。
include <iostream>
using namespace std;
template <typename T>
T fun(T a, T b) {return (a<=b)?a:b;}
int main()
{
cout<<fun(3,6)<<','<<fim(3.14F, 6.28F)<<end 1;
return 0;
}
第21题:
以下程序的输出结果是( )。 #include <iostream> using namespace std; int main(){ int a=1,b; switch(a){ case 1:b=30; case 2:b=20; case 3:b=10; default:b=0; } cout<<b<<endl; return 0; }
A.30
B.20
C.10
D.0
第22题:
以下程序的运行结果是【 】。
include<iostream>
include<string>
using namespace std;
void main(){
chara[10]="China",b[]="Chin",c[]="ese";
cout<<strlen(strcat(strcpy(a,b),c))<<endl;
}
第23题:
若有以下程序: #include <iostream> using namespace std; int main() { int a=3; cout<<(a+=a-=a+A) <<end1; return 0; } 程序执行后的输出结果是( )。
A.-6
B.12
C.0
D.-12
第24题:
以下程序输出的结果是( )。 #include<iostream> using namespace std; int main() { int **x,*y,z=10; y=&z; x=&y; cout<< **x+1<<endl; return 0; }
A.11
B.x的地址
C.y的地址
D.运行错误