行和列相乘表 [英] Multiplication table with rows and columns

查看:80
本文介绍了行和列相乘表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使乘法表看起来像这样: http://i.imgur.com/rR6JSua.png 吗?

How can I make multiplication table to look like this: http://i.imgur.com/rR6JSua.png ?

使用我的代码,它只有一列.

With my code it only has one column.

#include<stdio.h>

int main()
{
    int i, j;

    for(i = 1;i <= 9;i++)
    {   
        for(j = 1;j <= 9;j++)
        {
            printf("%d * %d  = %d\n",i , j,i*j);
        }
        printf("%d * %d = %d\n",i , 10,i*10);
        printf("\n");
    } 

    return 0;
}

推荐答案

尝试一下:

#include<stdio.h>

int main()
{
    int i, j;

for(i = 1;i <= 9;i+=3)
{

  for(j = 1;j <= 10;j++)
  {

       printf("%2d * %2d = %2d ",i , j,(i)*j);
       printf("%2d * %2d = %2d ",i+1 , j,(i+1)*j);
       printf("%2d * %2d = %d\n",i+2, j,(i+2)*j);
  }
  printf("\n");
} 
return 0;

}

这篇关于行和列相乘表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆