找考题网-背景图
未分类题

有如下程序 #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)

A.345<<_______<<34.567;
B.345**34.567
C.setprecision(3)
B.fixed
C.setfill('*')

【参考答案】

D
解析:本题考查的是输出的格式控制。本例中,操作符setprecision的作用是设置浮点数的精度;操作符fixed的作用是让浮点数按定点格式输出;操作符setfill的作用是设置填充字符;操作符setw的作用是设置输入输出的宽度。宽度设置setw是所有格式设置中惟一的一次有效的设置,即设...

(↓↓↓ 点击‘点击查看答案’看完整答案 ↓↓↓)
热门试题