1
3 2
4 5 6
10 9 8 7
。。。
#include<iostream>
#include<vector>
using namespace std;
void tri(int n){
//init vector
//line
for(int i=1;i<=n;i++){
//odd line begin 1,2,3...
if(i%2){
int aux=(i-1)*i/2+1;
//every line numbers count
for(int j=1;j<=i;j++){
cout<<aux<<" ";
aux++;
}
cout<<endl;
} else{
int aux=i*(i+1)/2;
for(int j=1;j<=i;j++){
cout<<aux<<" ";
aux--;
}
cout<<endl;
}
}
}
int main(){
tri(5);
return 0;
}