+ 1

string handling.

A sentence is entered from the keyboard in which words are separated by spaces. Determine how many words in this sentence begin and end with the same char example: 1. "my friend did not do this". Output: did 2. "He speaks with his aunt" . Output: speaks

17th Apr 2018, 7:13 AM
Cheerful dead man
Cheerful dead man - avatar
4 Antworten
+ 3
Something like this? #include <string> #include <iostream> int main() { std::string text; while(std::cin >> text) { if(text.size() > 1 && (text.at(0) == text.at(text.size() - 1))) std::cout << text << "\n"; } }
17th Apr 2018, 8:51 AM
Ipang
+ 2
#Python rules print(*[i for i in input().split() if i[0].lower()==i[-1].lower()])
17th Apr 2018, 8:03 AM
Louis
Louis - avatar
+ 2
This question is terribly worded. "one letter" implies a single character. As per your example, the question should read "the same letter"
17th Apr 2018, 9:01 AM
non
+ 1
wow. many thanks
17th Apr 2018, 8:58 AM
Cheerful dead man
Cheerful dead man - avatar