#include <iostream>
#include <string>
// input data
std::string identifier;
int main() {
std::string word;
int occurrences = 0;
std::cin >> identifier;
char c;
while ((c = getchar()) != EOF) {
//Controllo se il carattere possa far parte di un identificatore
if((c < 48 || (c > 57 && c < 65) || (c > 90 && c < 97) || c > 122) && c != 95){
//Se non ne fa parte controllo se la parola precedente è uguale all'identificatore, la azzero e
//controllo per commenti o stringhe
if(word == identifier)
++occurrences;
word = "";
if(c == 34){
do{
c = getchar();
}while(c != 34 && c != '\n');
}
else if(c == 47){
c = getchar();
if(c == 47){
do{
c = getchar();
}while(c != '\n');
}
else if(c == 42){
do{
c = getchar();
}while(c != 42);
c = getchar();
}
}
}
//Se il carattere può far parte dell'identificatore lo appendo alla fine della parola
else{
word += c;
}
}
std::cout << occurrences; // print the result
return 0;
}
Non capisco perché ma i subtask 002, 004 e 009 falliscono per output sbagliato. Qualcuno riesce ad aiutarmi?