【C语言 & C++】对齐输出九九乘法口诀

时间:2022-07-03 01:09:35
//对齐输出九九乘法口诀
#include <iostream>
#include <iomanip.h>
//using namespace std;
int main()
{
	int i,j;
	for(i=1;i<=9;i++)
	{
		for(j=1;j<=i;j++)
		{
			cout<<i<<"*"<<j<<"="<<setw(2)<<i*j<<"  ";
		}
		cout<<endl;
	}
	return 0;
}
/*
#include <stdio.h>
int main()
{
	int i,j;
	for(i=1;i<=9;i++)
	{
		for(j=1;j<=i;j++)
		{
			printf("%2d*%2d=%2d ",i,j,i*j);
		}
		printf("\n");
	}
	return 0;
}
*/
<img src="https://img-blog.csdn.net/20150516100750270?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZG91ZG91d2ExMjM0/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />