CCF NOI1033. 乘法口诀 (C++)

版权声明:代码属于原创,转载请联系作者并注明出处。 https://blog.csdn.net/weixin_43379056/article/details/84935695

1033. 乘法口诀

题目描述

根据给定的n,输出乘法口诀表的前n行。

输入

输入正整数n。

输出

输出乘法口诀的前n行。

样例输入

3

样例输出

1*1=1
1*2=2 2*2=4
1*3=3 2*3=6 3*3=9

数据范围限制

1<=n<=9

C++代码

#include <iostream>
#include <cassert>

using namespace std;

int main()
{
    int n;

    cin >> n;

    assert(1<=n && n<=9);

    for(int row=1; row<=n; row++)
    {
        for(int col=1; col<=row; col++)
        {
            cout << col << "*" << row << "=" << col*row << " ";
        }
        cout << endl;
    }

    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43379056/article/details/84935695