0

Write a program that can reverse the words in a given sentence without breaking the order.

For example "Hello world" will return "olleH dlrow", NOT "dlrow olleH"

1st Apr 2018, 1:00 PM
Shakil
Shakil - avatar
3 Respuestas
+ 13
#My try ☺️ #python (1 liner) print(" ".join(str[::-1] for str in input().split(" ")))
1st Apr 2018, 1:26 PM
🌛DT🌜
🌛DT🌜 - avatar
1st Apr 2018, 1:14 PM
LordHill
LordHill - avatar
0
#include <iostream> #include <string> using namespace std; int main(){ string a[100]; int n = 0; string s = ""; for (char c; (c = getchar()) != '\n';) { if (c == ' ') { a[n] = s; n++; s = ""; } else { s += c; } } a[n] = s; n++; for (int i = 0; i < n; i++) { reverse(a[i].begin(), a[i].end()); cout « a[i] « " "; } }
1st Apr 2018, 1:17 PM
Sulaiman
Sulaiman - avatar