子串
| Time Limit: | 1000MS | Memory Limit: | 65536KB |
|---|---|---|---|
| Total Submissions: | 196 | Accepted: | 80 |
Description:
给你一个字符串s1,在给你一个字符串s2,判断一下字符串s2是不是s1的子串!
Input:
只有一组测试数据,第一行为s1,第二行为s2,字符串长度小于100
Output:
如果s2是s1的子串,输出yes,否则输出no
Sample Input:
aabcdcd
Sample Output:
yes
Source:
#include <stdio.h>
#include <string.h>
bool isSub(char a[100],char b[100])
{
if(strlen(a)<strlen(b))
return 0;
else{
if(strstr(a,b)==NULL)
return 0;
else
return 1;
}
}
int main()
{
char a[100],b[100];
gets(a);
gets(b);
if(isSub(a,b))
printf("yes");
else
printf("no");
return 0;
}
\
\
\