fork download
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. char str[100] = "abacba";
  5.  
  6. int check()
  7. {
  8. int i;
  9. for(i = 0 ; i < strlen(str)-1 ; i++)
  10. {
  11. if(str[i] != str[i+1])
  12. {
  13. return 1;
  14. }
  15. }
  16. return 0;
  17. }
  18.  
  19. int main()
  20. {
  21. int i;
  22. int j;
  23. while(check())
  24. {
  25. for(i = 0 ; i < strlen(str) ; i++)
  26. {
  27. if(str[i]+str[i+1] == 'a'+'b')
  28. {
  29. str[i] = 'c';
  30. }
  31. else if(str[i]+str[i+1] == 'b'+'c')
  32. {
  33. str[i] = 'a';
  34. }
  35. else if(str[i]+str[i+1] == 'c'+'a')
  36. {
  37. str[i] = 'b';
  38. }
  39.  
  40. j = i+1;
  41. while(j < strlen(str)-1)
  42. {
  43. str[j] = str[j+1];
  44. j++;
  45. }
  46. str[j] = '\0';
  47. }
  48. }
  49. printf("%s" , str);
  50. return 0;
  51. }
Success #stdin #stdout 0.01s 1720KB
stdin
Standard input is empty
stdout
b