串結構練習——字符串匹配
Time Limit: 1000ms Memory limit: 65536K 有疑問?點這裏^_^
題目描述
輸入
輸出
示例輸入
abc a 123456 45 abc ddd
示例輸出
YES YES NO
提示
來源
示例程序
///strstr是字符串匹配函數,如果字符串str2是字符串str1的子串,則strstr返回值爲非空,否則返回值爲NULL
- #include<stdio.h>
- #include<string.h>
- int main()
- {
- char str1[100], str2[100];
- while(scanf("%s %s", str1, str2)!=EOF)
- {
- if(strstr(str1, str2)!=NULL)
- printf("YES\n");
- else
- printf("NO\n");
- }
- }