fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <cctype>
  4. using namespace std;
  5.  
  6. void modify(string& s) {
  7.  
  8. for (int i = 0; i < (int)s.size(); i++) {
  9. if (s[i] == '$') {
  10. s.erase(i, 1);
  11. }
  12. else if (s[i] == '&') {
  13. s[i] = '*';
  14. }
  15. else if (s[i] == '%') {
  16. s.replace(i, 1, "!!");
  17. }
  18. }
  19.  
  20. string w[200];
  21. int n = 0;
  22. string temp = "";
  23.  
  24. for (int i = 0; i <= (int)s.size(); i++) {
  25. if (i == (int)s.size() || s[i] == ' ') {
  26. if (!temp.empty()) {
  27. w[n++] = temp;
  28. }
  29. temp.clear();
  30. }
  31. else {
  32. temp += s[i];
  33. }
  34. }
  35.  
  36.  
  37. for (int i = 0; i < n; i++) {
  38. if (!w[i].empty() && isalpha((unsigned char)w[i][0])) {
  39. for (char& c : w[i]) {
  40. c = toupper((unsigned char)c);
  41. }
  42. }
  43. }
  44.  
  45.  
  46. for (int i = 1; i < n; i += 2) {
  47. w[i] = "*";
  48. }
  49.  
  50.  
  51. s.clear();
  52. for (int i = 0; i < n; i++) {
  53. if (i > 0) s += ' ';
  54. s += w[i];
  55. }
  56. }
  57.  
  58. int main() {
  59. string s;
  60. while (getline(cin, s)) {
  61. modify(s);
  62. cout << s << endl;
  63. }
  64. return 0;
  65. }
Success #stdin #stdout 0.01s 5324KB
stdin
111 & 000 equeals 0
stdout
111 * 000 * 0