#include<iostream.h> #include<conio.h> void main() { clrscr(); int i,j,k,l,n,x; cout<<"Please put number : "; cin>>n; i=j=k=l=1; x=2*n-1; while(x>=l) { if(i<=j) cout<<i<<" "; if(i==j) { cout<<"\n"; if(k==1) j++; else j--;//k==0 if(j==n) k=0; i=0; l++; } i++; } getch(); } //Please put number : 5 //1 //1 2 //1 2 3 //1 2 3 4 //1 2 3 4 5 //1 2 3 4 //1 2 3 //1 2 //1
ไม่มีความคิดเห็น:
แสดงความคิดเห็น