編寫函數int fun(char *s1,char *s2),在字符串s1中統計字符串s2出現的次數並返回。若s2在s1中未出現,則返回0。例如:
若輸入的字符串s1為:abaaAabcaabbabca,字符串s2為:ab ,則程序輸出:n=4
若輸入的字符串s1為:abaaAabcaabbabca,字符串s2為:abd,則程序輸出:No find
#include
#include
int fun(char *s1,char *s2)
{
}
int main()
{ char a[80],b[80];
int n;
printf("Please input the first string:");
gets(a);
printf("Please input the second string:");
gets(b);
n=fun(a,b);
if(n==0)
printf("No find\n");
else printf("n=%d\n",n);
return 0;
}
忘貼圖了