Advertisement
theo830

stringwithrules

Apr 5th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<list>
  4. #include<algorithm>
  5. using namespace std;
  6. int main(){
  7. int a;
  8. cin>>a;
  9. int x = 0;
  10. string b;
  11. int y;
  12. list<char> z;
  13. for(int i=0;i<a;i++){
  14. cin>>b;
  15. x = 0;
  16. y = b.size();
  17. sort(b,b+y);
  18. if(b[y-1] != 'C'){
  19. cout<<b<<endl;
  20. }
  21. else{
  22. for(int i=0;i<y;i++){
  23. z.push_back(b[i]);
  24. }
  25. while(z.end() == 'C' && z.front() == 'A'){
  26. z.pop_front();
  27. z.push_back('A');
  28. for(int i=0;i<z.size();i++){
  29. cout<<z.front();
  30. z.pop_front();
  31. }
  32. cout<<endl;
  33. }
  34. }
  35. }
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement