1. 程式人生 > >演算法訓練 乘法表

演算法訓練 乘法表

問題描述

  輸出九九乘法表。

輸出格式

  輸出格式見下面的樣例。乘號用“*”表示。

樣例輸出

下面給出輸出的前幾行: 1*1=1 2*1=2 2*2=4 3*1=3 3*2=6 3*3=9 4*1=4 4*2=8 4*3=12 4*4=16 ……

#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
    for(int i=1; i<=9; i++)
    {
        for(int j=1; j<=i; j++)
        {
            cout << i << "*" << j << "=" << i*j << " ";
        }
        cout << endl;
    }
    return 0;
}