Advertisement
theo830

stringwithrules

Apr 5th, 2019
115
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. for(int i=0;i<y;i++){
  18. z.push_back(b[i]);
  19. }
  20. sort(z.begin(),z.end());
  21. if(b[y-1] != 'C'){
  22. cout<<b<<endl;
  23. }
  24. else{
  25.  
  26. while(z.back() == 'C' && z.front() == 'A'){
  27. z.pop_front();
  28. z.push_back('A');
  29. for(int i=0;i<z.size();i++){
  30. cout<<z.front();
  31. z.pop_front();
  32. }
  33. cout<<endl;
  34. }
  35. }
  36. }
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement