#include <stdio.h> //a查找范围 b查找目标 int fun(char *a,char *b) { int n=0; while(*a) { if(*a==*b) n++; a++; } return n; } int main() { char zf[]="我喜欢我我我我C语言",zf1[]="我"; printf("%d",fun(zf,zf1)); getchar(); }
2024-04-11 14:49:43
#include <stdio.h> //a查找范围 b查找目标 int fun(char *a,char *b) { int n=0; while(*a) { if(*a==*b) n++; a++; } return n; } int main() { char zf[]="我喜欢我我我我C语言",zf1[]="我"; printf("%d",fun(zf,zf1)); getchar(); }