用C++ Builder 如何编写这个程序啊?

来源:百度知道 编辑:UC知道 时间:2024/06/01 23:31:10
1
2 3
4 5 6
7 8 9 10
这是个小程序
用c++怎么编写?谁能告诉我吗?

#include <iostream>
using namespace std;
int main()
{
int n=1;
for (int a=1; a<5; a++)
{
for (int b=1; b<=a; b++)
{
cout << n++ << '\t';
}
cout << endl;
}
}

#include <iostream>
using namespace std;
int main()
{
int i,n,m=1;
for(i=1;i<=4;i++)
{
for(n=1;n<=i;n++)
{

cout<<m+++" ";
}
cout<<"\n";
}
}

我是用JAVA写的,c++的语法不是很熟哈