// 2022 IUSB Programming Competition // Round 1 Problem 3 // Text Editing // Solution by Liguo Yu #include #include using namespace std; string remove(string s); int main() { char input[300]; cin.getline(input, 300); string myinput = input; string result = remove(myinput); cout << result; return 1; } string remove(string s) { string result = ""; bool space_flag = false; bool begining = true; for (int i = 0; i < s.length(); i++) { char c = s.at(i); if (c != ' ') { if (begining == false && space_flag == true && c != '.' && c != ',' && c != '?') { result = result + ' '; } result = result + c; begining = false; space_flag = false; } else // (c == ' ') { if (space_flag == false) { space_flag = true; } } } return result; }