题目链接

A题 :(字符串查找,水题)

题意 :输入字符串,如果字符串中包含“ Apple”, “iPhone”, “iPod”, “iPad” 就输出 “MAI MAI MAI!”,如果出现 “Sony” 就输出“SONY DAFA IS GOOD!” ,大小写敏感。

思路 : 字符串查找,水题。

 1 #include <string.h>
 2 #include <stdio.h>
 3 #include <iostream>
 4 
 5 using namespace std ;
 6 
 7 char str[20000];
 8 
 9 int main()
10 {
11     int i;
12     while(gets(str))
13     {
14         int len=strlen(str);
15         for(i=0; i<len; i++)
16         {
17             if(str[i]=='A' && str[i+1]=='p' && str[i+2]=='p' && str[i+3]=='l' && str[i+4]=='e')
18                 printf("MAI MAI MAI!\n");
19             if(str[i]=='i' && str[i+1]=='P' && str[i+2]=='h' && str[i+3]=='o' && str[i+4]=='n'&&str[i+5] == 'e')
20                 printf("MAI MAI MAI!\n");
21             if(str[i]=='i' && str[i+1]=='P' && str[i+2]=='a' && str[i+3]=='d')
22                 printf("MAI MAI MAI!\n");
23             if(str[i]=='i' && str[i+1]=='P' && str[i+2]=='o' && str[i+3]=='d')
24                 printf("MAI MAI MAI!\n");
25             if(str[i]=='S' && str[i+1]=='o' && str[i+2]=='n' && str[i+3]=='y')
26                 printf("SONY DAFA IS GOOD!\n");
27         }
28     }
29     return 0;
30 }
View Code

相关文章:

  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2021-10-27
  • 2021-11-02
  • 2022-12-23
  • 2022-01-16
  • 2021-07-21
猜你喜欢
  • 2021-08-29
  • 2021-09-06
  • 2022-12-23
  • 2022-01-24
  • 2021-12-27
  • 2022-02-15
相关资源
相似解决方案