有如下程序: #inc1ude<iostream> using namespace.std; int main() { cout.fill(’*’); cout.width(6); cout.fill

admin2016-11-23  20

问题 有如下程序:
    #inc1ude<iostream>
    using namespace.std;
    int main()
    {
    cout.fill(’*’);
    cout.width(6);
    cout.fill(’#’);
    cout<<123<<end1;
    retum 0;
    }
    执行后的输出结果是(     )。

选项 A、###l23
B、123###
C、***l23
D、123***

答案A

解析 此题考查的是I/O格式化输出。函数width(int n)设置输入输出宽度,当实际数据宽度小于制定的宽度时,多余的位置用填充字符填满:当实际数据宽度大于设置的宽度时,仍按实际宽度输出:函数fill(char c)用来设置填充字符。
转载请注明原文地址:https://kaotiyun.com/show/VsAp777K
0

最新回复(0)