更多"有如下程序
#include<iostream.h>
vo"的相关试题:
[单项选择]有如下程序
#include<iostream.h>
voidmain( )
{ charch[2][5]={"6937","8254"},*p[2];
inti,j,s=0;
for(i=0;i<2;i++)p[i]=ch[i];
for(i=0;i<2;i++)
for(j=0;p[i][j]>,/’’0’’,;j+=2)
s=10*s+p[i][j]-’’0’’;
cout<<S;}
该程序的输出结果是( )。
A. 选择和投影
B. 投影和选择
C. 选择和联接
D. 投影和联接
[单项选择]有下列程序:
#include
voidmain()
{char*a[]={"abcd","ef","gh","ijk");inti;
for(i=0;i<4;i++)printf("%C",*a[i]);
}
程序运行后的输出结果是( )。
A. aegi
B. dfhk
C. abcd
D. abcdefghijk
[填空题]以下程序输出的结果是 【7】 。
#include<iostream.h>
voidmain( )
inta=5,b=4,c=3,d;
d=(a>b>c);
cout<<d;
[填空题]下面程序的结果为 【7】 。
#include<iostream.h>
voidmain( )
int a=1,b=2;
bool c=1;
if((a>b)||(c)cout <<"ture" <<end1;
else
cout <<"false" <<end1;
[填空题]下列程序的输出结果为 【8】 。
include<iostream.h>
voidmain( )inta []=10,20,30,40,*pa=a;
int*&ph=pa;
Pb++;
cout<<*pa<<end1;
[单项选择]有如下程序
#include
#include
using namespace std;
class MyClass{
public:
MyClass( ){cout<<′A′;}
MyClass(char c){cout<<′c′;}
MyClass( ){cout<<′B′;}
}
int main( ){
MyClass pl,*p2;
p2=new MyClass(′X′);
delete p2;
retum 0;
}
执行这个程序屏幕上将显示输出【 】
A. ABX
B. ABXB
C. AXB
[单项选择]有如下程序
#include
#include
using namespace std;
int main( )
cout<A. setprecision(3)
B. fixed
C. setfill(′*′)
D. setw(8)
[简答题]有如下程序
#include
#include
using namespace std;
class MyClass{
public:
MyClass( ){cout<<’A”;}
MyClass(char c {cout<A. A.ABX
B.ABXB
C.AXB
D.AXBB
[单项选择]有如下程序:
#include
#include
using namespace std;
class MyString{
public;
char str[80];
MyString(const char*s) {strcpy(str,s);}
MyString&operator+=(MyString a){
strcat(str,a.str);
return*this;
}
};
ostream&operator<<(ostream&s,const MyString&z){return s << z.str}
int main( ){
MyString x("abc"),y("cde");
cout<<(x+=y)<A. abc
B. cde
C. abcde
D. abccde
[单项选择]有如下程序:
#include
usingnamespacestd;
intmain()
{
int*P;
*P=9:
cout<<"ThevalueatP:"<<*P;
return0;
}
编译运行程序将出现的情况是( )。
A. 编译时出现语法错误,不能生成可执行文件
B. 运行时一定输出ThevalueatP:9
C. 运行时一定输出ThevalueatP:*9
D. 运行时有可能出错
[单项选择]有如下程序:
#include
using namespace std;
class Boat;
class Car{
public:
Car(int i):weight(i){ }
friend int Total(const Car &c.const Boat &b); //①
private:
int weight;
};
class Boat{
public:
Boat(int i):weight(i){ }
friend int Total(const Car &c,const Boat &b);
private:
int weight;
};
int Total(const Car &c,const Boat &b){ //②
return c.weight+b.weight;
}
int main( ){
Car c(10);
Boat b(8);
cout<<"The total weight is"<A. 程序编译正确
B. 程序编译时语句①出错
C. 程序编译时语句②出错
D. 程序编译时语句③出错
[单项选择]有如下程序
#include <iostream>
#include <iomanip>
using namespace std;
int main( )
cout<<setprecision(3)<<fixed<<setfill(’*’)<<setw(8);
cout<<12.345<<__________<<34.567;
return 0;
若程序的输出是:
**12.345**34.567
则程序中下划线处遗漏的操作符是( )。
A. setprecision(3)
B. fixed
C. setfill(’*’)
D. setw(8)