Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- int main()
- {
- char str[100],c[1];
- int str1[100];
- int i,a,s,b,x,y,w;
- while(gets(c)!=NULL)
- {
- x=0;y=0;w=0;
- gets(str);
- a=strlen(str);
- b=str[0];
- s=1;
- for(i=1;i<a;i++)
- {
- if(b==str[i])
- {
- s++;
- }
- else
- {
- if(s==2||s==1)
- {
- x++;
- }
- y++;
- str1[w]=s;
- str1[w+1]=b;
- w=w+2;
- b=str[i];
- s=1;
- }
- }
- if(s==2||s==1)
- {
- x++;
- }
- y++;
- str1[w]=s;
- str1[w+1]=b;
- if(x!=y)
- {
- for(i=0;i<=w+1;i++)
- {
- if(i%2==0)
- {
- printf("%d",str1[i]);
- }
- else
- {
- printf("%c",str1[i]);
- }
- }
- }
- else
- {
- for(i=0;i<a;i++)
- {
- printf("%c",str[i]);
- }
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement