C++ 指定输出宽度和填充

#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
    cout << 123 << endl;
    cout.width(10);
    cout << 123 << endl;
    cout << 123 << endl;
    cout.width(1);
    cout << 123 << endl;
    cout.width(10);
    cout.fill('*');
    cout << 123 << endl;
    cout.width(10);
    cout << 123 << endl;
    return 0;
}

 

posted @ 2014-04-12 23:11  秋月的私语  阅读(2690)  评论(0编辑  收藏  举报