|
|
back to boardWA 1st test. I dont understand why. Help pls) Posted by mrFOXY 19 Apr 2021 11:06 #include <iostream> #include <vector> #include <cmath> #include <string> #include <stack> using namespace std; string solve(string text) { string ts, cs = "", ans = ""; int i = 0; while (i < text.size()) { while(int(text[i]) >= 65 && int(text[i]) <= 122) { ts = ""; // create temp string ts.push_back(text[i]); // translate char to string cs.insert(0, ts); //reverse string i++; } if (i > 0 && int(text[i-1]) >= 65 && int(text[i-1]) <= 122) { ans += cs; //plus to out ans cypher word cs = ""; // make cypher word "" }
ans+=text[i]; i++; } ans += char(0x20); ans += char(0x0a); return ans; } int main() { string s; while(getline(cin, s)) cout << solve(s); } |
|
|