题意:有iPhone iPad iPod Apple这些词出现就输出MAI MAI MAI! 有Sony输出。。。
题解:水题。
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
string str;
int main() {
while (getline(cin, str)) {
int len = str.length();
for (int i = 0; i < len; i++) {
if (str[i] == 'A' && str[i + 1] == 'p' && str[i + 2] == 'p' && str[i + 3] == 'l' && str[i + 4] == 'e')
printf("MAI MAI MAI!\n");
else if (str[i] == 'i' && str[i + 1] == 'P' && str[i + 2] == 'a' && str[i + 3] == 'd')
printf("MAI MAI MAI!\n");
else if (str[i] == 'i' && str[i + 1] == 'P' && str[i + 2] == 'o' && str[i + 3] == 'd')
printf("MAI MAI MAI!\n");
else if (str[i] == 'i' && str[i + 1] == 'P' && str[i + 2] == 'h' && str[i + 3] == 'o' && str[i + 4] == 'n' && str[i + 5] == 'e')
printf("MAI MAI MAI!\n");
else if (str[i] == 'S' && str[i + 1] == 'o' && str[i + 2] == 'n' && str[i + 3] == 'y')
printf("SONY DAFA IS GOOD!\n");
}
}
return 0;
}