Advertisement
lily09290110

壓縮

Jan 13th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.30 KB | None | 0 0
  1. #include<stdio.h>
  2. int i=0;
  3. void str(char com[25],char print_com[250],int count,int *count_flat)
  4. {
  5.     int j,k,temp,turn_num,scripearr,addres_str[2],addres_end[2];
  6.     for(;com[i]!='\0';i++){
  7.         if(com[i]<='z'&&com[i]>='a') print_com[(*count_flat)++]=com[i];
  8.         if(com[i+1]<='9'&&com[i+1]>='0'){
  9.             temp=0;scripearr=i;
  10.             if(com[scripearr]==')'){
  11.               addres_end[count-1]=*count_flat-addres_str[count-1];
  12.             }
  13.             do{
  14.               i++;
  15.               turn_num=com[i]-48;
  16.               temp=temp*10;
  17.               temp=temp+turn_num;
  18.             }while(com[i+1]<='9'&&com[i+1]>='0');
  19.             (com[scripearr]==')')?{
  20.                 for(j=0;j<temp-1;j++)
  21.                    for(k=0;k<addres_end[count-1];k++)
  22.                        print_com[(*count_flat)++]=print_com[k+addres_str[count-1]];
  23.                 count--;
  24.                }:(
  25.                for(j=0;j<temp-1;j++)
  26.                print_com[(*count_flat)++]=com[scripearr];
  27.                   );
  28.         }
  29.          if(com[i]=='('){
  30.             addres_str[count]=*count_flat;count++;
  31.         }
  32.     }
  33. }
  34. main (count_flat,com[25])
  35. {
  36.     char print_com[250];
  37.     scanf("%s",com);
  38.     str(com,print_com,0,&count_flat);
  39.     print_com[count_flat]='\0';
  40.     printf("%s",print_com);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement