#include "stdafx.h"
#include<iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int n=0;
cout<<"Please enter a number: ";
while(cin>>n)
{
for(int i=0;i<n;i++)//外循环--行
{
int f=i+1;
int step=n;
//输出行前的空格
for(int j=0;j<i;j++)
cout<<"\t";
<span style="white-space:pre"> </span>//输出每一行的数字和前面的空格
for(int k=i;k<n;k++)
{
cout<<f<<"\t";
f=f+step;
step--;
}
cout<<endl;
}
cout<<"Please enter a number: ";
}
return 0;
}
效果图:
<img src="https://img-blog.csdn.net/20150123100009974" alt="" />