有如下程序 #include #include using namespace std; int main(){ cout

admin2020-11-11  21

问题 有如下程序
    #include
    #include
    using namespace std;
    int main(){
    cout<    cout<<12.345<<__________<<34.567;
    return 0;
    }
    若程序的输出是:
    **12.345**34.567
    则程序中下划线处遗漏的操作符是(    )。

选项 A、setprecision(3)
B、fxed
C、setfill(’*’)
D、setw(8)

答案D

解析 此题考查的是输出函数的格式控制。此题中,操作符setprecision的作用是设置浮点数的精度;fixed的作用是让浮点数按定点格式输出;setfill的作用是设置填充字符;setw的作用是设置输入输出的宽度,一次有效的设置。下划线处应填一个让34.567的输出宽度为8的操作符,即setw(8)。
转载请注明原文地址:https://kaotiyun.com/show/T0yp777K
0

随机试题
最新回复(0)