Немного порылся в интернете по пайтону:
text = input('введите текст ')
print(list(filter(lambda x: x.startswith(“а”), text.split())))
print(list(filter(lambda x: x.endswith(“а”), text.split())))
Но может кто то помочь именно по коду?
Код на С++
#include <iostream> #include <string> #include <sstream> using namespace std; int main() { setlocale(LC_ALL, "Russian"); string s; [code css] cout << "Input words:" << endl; getline(cin, s); stringstream strm(s); cout << "Your words:" << endl; int wcount{ 0 }; for (string i; strm >> i { int lenght = i.length() - 1; if (i[0] == i[lenght]) { cout << i << endl; wcount++; } else if ((i[lenght] == '!') || (i[lenght] == '?') || (i[lenght] == '.')) { i.erase(lenght--); if (i[0] == i[lenght]) { cout << i << endl; wcount++; } } } if (!wcount) cout << "Didnt found!"; getchar(); return 0; }