有如下4个语句:①cout~A~setfill(~*~)leftsetw(7)~B~endl;②coutsetfill(~*~)leftsetw(7)~A~~B~endl;③cout~A~serfill(~*~)rightsetw(7)~B~endl;④coutsetfill(~*~)rightsetw(7)~A~~B~endl;其中能显示A******B的是
A、①和③
B、①和④
C、②和③
D、②和④
第1题:
有如下4个语句: ①count<<'A'<<setfill('x')<<left<<setw(7)<<'B'<<endl; ②count<<setfill('x')<<left<<setw(7)<<'A'<<'B'<<endl; ③count<<'A'<<setfill('*')<<right<<setw(7)<<'B'<<endl; ④count<<setfill('x')<<right<<setw(7)<<'A'<<'B'<<endl; 其中能显示A * * * * * * B的是
A.①和③
B.①和④
C.②和③
D.②和④
第2题:
有如下四个语句: ①cout<<A<<seifill(*)<<left<<setw(7)<<B<<endl; ②cout<<setfill(*)<<left<<setw(7)<<A<<B<<endl; ③cout<<A<<serfill(*)<<right<<setw(7)<<B<<endl; ④cout<<setfill(*)<<right<<setw(7)<<A<<B<<endl; 其中能显示A******B的是( )。
A.①和③
B.①和④
C.②和③
D.②和④
C。【解析】本题考查C++流的使用。setfill的作用是设置填充字符;left的作用是使输出数据在指定宽度内左对齐;right的作用是使输出数据在指定宽度内右对齐。
第3题:
5.以输出宽度为 8 输出变量 x 值的语句是()。
A.(A)cout<<setw(8)<<x<<endl;
B.(B)cout<<oct<<x<<endl;
C.(C)cout<<setprecision(8)<<x<<endl;
D.(D)cout<<setfill(8)<<x<<endl;
第4题:
有如下4个语句: ①cout<<‘A’<<setfill(‘*’)<<1eft<<setw(7)<<‘B’<<endl; ②cout<<setrill(‘*’)((1eft<<setw(7)<<‘A’<<‘B’<<endl; ③cout<<‘A’<<serfill(‘*’)<<right<<setw(7)<<‘B’<<endl; ④cout<<setfill(‘x’)<<right<<setw(7)<<‘A’<<‘B’<<endl;
A.①和③
B.①和④
C.②和③
D.②和④ 其中能显示A* * * * * *B的是( )。
第5题:
下列语句中,输出与众不同的是
A.cout<<"1."<<setfill('')<<"Hello!"<<endl;
B.cout<<"1."<<''<<"Hello! \n";
C.cout<<"1. Hello!"<<endl;
D.cofit<<"1."<<setw(7)<<"Hello!";