C++打印个乘法表玩玩

来源:互联网 发布:淘宝上最贵的商品 编辑:程序博客网 时间:2024/06/05 16:08

练习cout.width()时,想到乘法表。写着玩…

#include<iostream>int main(){    using std::cout;    using std::endl;    for (int i = 1; i <= 9; i++)    {        for (int j = 1; j < i + 1; j++)        {            cout.fill('||');            cout.width(2);//效果不佳,不如\t            cout << i << "*" << j << "=" << i*j << "\t";            cout.fill('*');        }        cout << endl;    }    return 0;}
0 0
原创粉丝点击