Advertisement
Guest User

ant

a guest
Mar 28th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.     int mainarr[30]={0}, temparr[30]={0};
  5.     int i,j,type,cnt,dir;
  6.  
  7.     printf("1\n");
  8.     mainarr[0]=1;
  9.  
  10.     for(i=0; i<9; i++){
  11.         j=0;
  12.         type=0;
  13.         cnt=0;
  14.         dir=0;
  15.         do{
  16.             if(type!=0){
  17.                 if(mainarr[j]==type) {
  18.                     cnt++;
  19.                 } else {
  20.                     printf("%d%d", type, cnt);
  21.                     temparr[dir]=type;
  22.                     temparr[dir+1]=cnt;
  23.                     dir+=2;
  24.                     type=mainarr[j];
  25.                     cnt=1;
  26.                 }
  27.             } else {
  28.                 type=mainarr[j];
  29.                 cnt=1;
  30.             }
  31.             j++;
  32.         }while(mainarr[j-1]!=0);
  33.         printf("\n");
  34.         for(j=j; j>0; j--) mainarr[j]=temparr[j];
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement