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;
}

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;
}
图片说明

图片说明

要这样?

 #include<iomanip>
#include<iostream>
using namespace std;
int main()

{
    int i,j;
    cout<<" 乘法口诀表 "<<endl;
    cout<<"--------------------------------------------------"<<endl;
    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;
    }
    cout<<"--------------------------------------------------"<<endl;
    system("pause");
    return 0;
}

图片说明

for for语句的循环嵌套打印9×9乘法表

for(var r=1;r<=9;r++){
for(var i=1,str=" ";i<=r;i++){
str+=i+"x"+r+"="+i*r+" ";
}
console.log(str)
}

。。。。。。。。。。。。图片

感谢大佬回答,学到了