Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int a[100][100]={0},i=3,j,n,k,m,w;
- cin>>n;
- a[1][1]=1;a[2][1]=1;a[2][2]=1;
- while(i<=n)
- {
- m=1;w=1;j=1;
- while(a[i-1][w]!=0)
- {
- k=1;
- while(a[i-1][j]==a[i-1][j+1])
- {
- k++;j++;
- }
- a[i][m]=k; a[i][m+1]=a[i-1][j];
- m+=2;j++;w+=k;
- }
- i++;
- }
- for(i=1;i<=n;i++)
- {
- for(j=1;j<=100;j++)
- if(a[i][j]!=0)
- cout<<a[i][j]<<' ';
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement