Two ways of thinking about the ninety-nine multiplication table

Law one:

#include<stdio.h>

int main(){
int i,j;
for(i=1;i<=9;i++)
printf("%2d ",i);
printf("\n");


for(i=1;i<=9;i++)
printf(" - ");
printf("\n");


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



Law two:

#include<stdio.h>
main()
{
int x,y,z;
for(x=1;x<=9;x++)
{
 for(y=1;y<=x;y++)
{
  z=x*y;
  printf("%d*%d=%d\t",y,x,z);
 }
 printf("\n");
}
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324845437&siteId=291194637