Odpowiedź:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
int main() {
std::string text = "pan papier pani kot pies pomidor";
std::istringstream ss(text);
std::string word;
int counter = 0;
while(ss >> word){
if(word.length() % 2 == 1 && std::tolower(word.front()) == 'p'){
counter++;
}
}
std::cout << counter;
return 0;
}
Wyjaśnienie:
Wynik 2, bo pan i pomidor