cout << setw(6) << 1 << setw(5) << 2 << setw(5) << 3 << setw(5) << 4 << setw(5) << 5 << setw(5) << 6 << setw(5) << 7 << setw(5) << 8 << setw(5) << 9 << endl;
for (i = 1; i <= 9; i++)
{
cout << i ;
for (j = 1; j <= i; j++)
cout << setw(5)<< i*j;
cout << endl;
}
for循环 乘法表 求解怎么样才能打印出第一列1~9的数字
#include
#include
using namespace std;
int main()
{
int i,j;
cout<<" 乘法口诀表 "<<endl;
cout<<"--------------------------------------------------"<<endl;
cout<<setw(5)<<1<<setw(5)<<2<<setw(5)<<3<<setw(5)<<4<<setw(5)<<5<<setw(5)<<6<<setw(5)<<7<<setw(5)<<8<<setw(5)<<9<<endl;
for(i=1;i<=9;i++)
{
for(j=1;j<=i;j++)
cout<<i*j<<setw(5);
cout<<endl;
}
cout<<"--------------------------------------------------"<<endl;
return 0;
}
- 点赞
- 写回答
- 关注问题
- 收藏
- 复制链接分享
- 邀请回答
7条回答
为你推荐
- for循环 乘法表 求解怎么样才能打印出第一列1~9的数字
- for
- 7个回答