https://www.acmicpc.net/problem/2857
큰 흐름은 아래와 같다.
여기서 2번 단계를 위해 find() 함수를 쓰는게 핵심이다.
#include <iostream>
#include <string>
using namespace std;
int main() {
string name[5];
int FBI[5];
int count = 0;
for (int i = 0; i < 5; i ++) {
cin >> name[i];
if (name[i].find("FBI") != string::npos) {
FBI[count] = i + 1;
count++;
}
}
if (!count) cout << "HE GOT AWAY!" << endl;
else {
for (int i = 0; i < count; i++) {
cout << FBI[i];
if (i != count - 1) cout << " ";
}
cout << endl;
}
return 0;
}