fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. void modify(string& s) {
  5. string result = "";
  6. string word = "";
  7. string clean = "";
  8. for (char c : s) {
  9. if (c == '%') clean += '!!';
  10. else if (c == '$') clean += '&';
  11. else if (c == '&') clean += '*';
  12. else clean += c;
  13. }
  14. for (int i = 0; i <= clean.size(); i++) {
  15. if (i == clean.size() || clean[i] == ' ') {
  16. if (word.find('*') == string::npos && word.find("!!") == string::npos && word.find("&") == string::npos) {
  17. for (int j = 0; j < word.size(); j++) {
  18. word[j] = toupper(word[j]);
  19. }
  20. }
  21. result += word + " ";
  22. word = "";
  23. }
  24. else {
  25. word += clean[i];
  26. }
  27. }
  28. s = result;
  29. }
  30. int main() {
  31. string s;
  32. getline(cin, s);
  33. modify(s);
  34. cout << s;
  35. return 0;
  36. }
Success #stdin #stdout 0.01s 5276KB
stdin
apples are great&$%
stdout
APPLES ARE great*&!