小作业(一个字符串中包含几个另一个字符串)
2014-10-30 08:56
85 查看
#include <stdio.h> #include <string.h> #define Num 1000 int main() { int i = 0,j = 0,k,count = 0,h = 0,c; char str1[Num],str2[Num],str3[Num]; printf("Please input the first string,and enter as the end:\n"); while((c = getchar()) != EOF && c != '\n') { str1[i] = c; i++; } printf("Please input the second string,and enter as the end:\n"); while((c = getchar()) != EOF && c != '\n') { str2[j] = c; j++; } if(i < j) { printf("str1 has 0 str2"); } else { for(k = 0;k < i - j + 1;k++) { for(h = 0;h < j;h++) { str3[h] = str1[k + h]; } if(strcmp(str3,str2) == 0) count++; } printf("str1 has %d str2s",count); } return 0; }
相关文章推荐
- 小作业(一个字符串中包含几个另一个字符串)
- 6.2删除一个字符串包含的另一个字符串
- 一次谷歌面试趣事- 判断一个字符串是否包含另一个字符串
- 如何判断一个字符串中是否包含另一个字符串
- 判断一个给定的字符串通过循环移位是否可以包含另一个字符串
- php怎样判断一个字符串是否包含另一个字符串strpos()
- 一个字符串是否包含另一个字符串的问题
- 一个字符串中是否包含另一个字符串
- php怎样判断一个字符串是否包含另一个字符串?
- php如何判断一个字符串是否包含另一个字符串
- 判断一个字符串里是否包含另一个字符串所有的字符
- php中判断一个字符串包含另一个字符串的方法
- 模仿String.indexOf,判断一个字符串是否包含另一个字符串
- C#中,怎么判断一个字符串包含是否不包含另一个字符串
- c语言中判断一个字符串是否包含另一个字符串
- php中判断一个字符串包含另一个字符串的方法
- 比较一个字符串是否包含另一个字符串 java
- 比较一个字符串是否包含另一个字符串 java
- 验证一个字符串里面是不是包含另一个字符串
- oracle中一个字符串包含另一个字符串中的所有字符