SDUT-2561 九九乘法表

来源:互联网 发布:windows凭据 编辑:程序博客网 时间:2024/05/16 16:17

九九乘法表

Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic Discuss

Problem Description

      九九乘法表是数学学习的基础,今天我们就来看看乘法表的相关问题。《九九乘法歌诀》,又常称为“小九九”,如下图所示。你的任务是写一个程序,对于给定的一个正整数 n ,输出“九九乘法表”的前 n 行。例如,输入 n 为 9,你的程序的输出将为下图: 

Input

输入包含多组测试数据,以 EOF 结束。每组测试数据只包含一个正整数 n (0 < n < 10)。

Output

对于每组测试数据,输出上图所示“九九乘法表”的前 n 行。

Example Input

23

Example Output

1*1=11*2=2 2*2=41*1=11*2=2 2*2=41*3=3 2*3=6 3*3=9

Code

#include<stdio.h>int main(){    int row,col,n;    while(scanf("%d",&n)!=EOF)    {        for(row=1; row<=n; row++)        {            for(col=1; col<=row; col++)            {                printf("%d*%d=%d",col,row,row*col);                if(col!=row)                    printf(" ");            }            printf("\n");        }    }    return 0;}

原创粉丝点击