题意:出现Apple、iPod、iPhone、iPad时输出MAI MAI MAI!,出现Sony,输出SONY DAFA IS GOOD!

Sample Input
Apple bananaiPad lemon ApplepiSony
233
Tim cook is doubi from Apple
iPhoneipad
iPhone30 is so biiiiiiig Microsoft
makes good App.

Sample Output
MAI MAI MAI!
MAI MAI MAI!
MAI MAI MAI!
SONY DAFA IS GOOD!
MAI MAI MAI!
MAI MAI MAI!
MAI MAI MAI!

 

 1 # include <iostream>
 2 # include <cstdio>
 3 # include <cstring>
 4 # include <string>
 5 # include <algorithm>
 6 # include <cmath>
 7 # include <queue>
 8 # define LL long long
 9 using namespace std ;
10 
11 
12 int main ()
13 {
14     //freopen("in.txt","r",stdin) ;
15     string s ;
16     while(cin>>s)
17     {
18         int len = s.size() ;
19         int i ;
20         for (i = 0 ; i < len ; i++)
21         {
22             string a = s.substr(i,4) ;
23             if (a == "iPad" ||a == "iPod")
24                 cout<<"MAI MAI MAI!"<<endl ;
25             else if (a == "Sony")
26                 cout<<"SONY DAFA IS GOOD!"<<endl ;
27             string b = s.substr(i, 5);
28             if (b == "Apple")
29                 cout<<"MAI MAI MAI!"<<endl ;
30             string c = s.substr(i, 6);
31             if (c == "iPhone")
32                 cout<<"MAI MAI MAI!"<<endl ;
33 
34         }
35     }
36 
37     return 0 ;
38 }
View Code

相关文章:

  • 2021-10-20
  • 2021-12-27
  • 2022-12-23
  • 2022-01-11
  • 2022-12-23
  • 2021-11-23
  • 2021-11-05
猜你喜欢
  • 2021-09-10
  • 2021-07-22
  • 2022-12-23
  • 2021-12-13
  • 2021-09-05
  • 2021-06-28
  • 2022-12-23
相关资源
相似解决方案