C++入门经典-例3.23-使用嵌套循环输出乘法口诀表

1:代码如下:

// 3.23.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iomanip>
#include <iostream>
using namespace std;
void main(void)
{
    int i,j;
    i=1;
    j=1;
    for(i=1;i<10;i++)
    {
        for(j=1;j<i+1;j++)
            cout << i << "*" << j << "=" << setw(2) << i*j ;//set(n)设置域宽为n字符,且靠右排列
        cout<< endl;
    }
}
View Code

运行结果:

posted @ 2017-09-14 08:54  一串字符串  阅读(385)  评论(0编辑  收藏  举报