Portál AbcLinuxu, 11. května 2025 02:36
> tekst.cc << KONEC cat #include <iostream> #include <sstream> #include <string> #include <cctype> #include <clocale> using namespace std; int main(void) { setlocale(LC_ALL, ""); string line, s; istringstream is; int i, j, k, a, b; while (getline(cin, line)) { is.clear(); is.str(line); while (is >> s) { for (a = 0; !isalpha(s[a]) && a < s.length(); a++); for (b = s.length() - 1; !isalpha(s[b]) && b >= 0; b--); for (j = a; j < (i = b - a + 1) / 2 - 1; j++) { k = s[j + 1]; s[j + 1] = s[i - j - 2]; s[i - j - 2] = k; } cout << s << " "; } cout << endl; } return 0; } KONEC g++ -o tekst tekst.ccP.S.: Už jsem ho tady jednou dával, ale připomenutí nikdy nezaškodí.
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.