Advertisement
rrick

Untitled

Jan 16th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main()
  4. {
  5. char str[100],c[1];
  6. int str1[100];
  7. int i,a,s,b,x,y,w;
  8. while(gets(c)!=NULL)
  9. {
  10. x=0;y=0;w=0;
  11. gets(str);
  12. a=strlen(str);
  13. b=str[0];
  14. s=1;
  15. for(i=1;i<a;i++)
  16. {
  17. if(b==str[i])
  18. {
  19. s++;
  20. }
  21. else
  22. {
  23. if(s==2||s==1)
  24. {
  25. x++;
  26. }
  27. y++;
  28. str1[w]=s;
  29. str1[w+1]=b;
  30. w=w+2;
  31.  
  32. b=str[i];
  33. s=1;
  34. }
  35. }
  36. if(s==2||s==1)
  37. {
  38. x++;
  39. }
  40. y++;
  41. str1[w]=s;
  42. str1[w+1]=b;
  43. if(x!=y)
  44. {
  45. for(i=0;i<=w+1;i++)
  46. {
  47. if(i%2==0)
  48. {
  49. printf("%d",str1[i]);
  50. }
  51. else
  52. {
  53. printf("%c",str1[i]);
  54. }
  55. }
  56. }
  57. else
  58. {
  59. for(i=0;i<a;i++)
  60. {
  61. printf("%c",str[i]);
  62. }
  63. }
  64. printf("\n");
  65. }
  66. return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement