题目内容
请补充函数proc(),该函数可以统计一个长度为n的字符串在另一个字符串中出现的次数。例如,假定输入的字符串为:fjdkad**fdadf fdadjkfdad,子字符串为ad,则应输出4。 注意:部分源程序给出如下。 请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdlib.h> #include<stdio.h> #include<string.h> #include<conio.h> int proc(char*str.char*sub) { int n; char*p,*r; n=0; while(*str) { p=str; r=sub; while(______) if(*r==*p) { r++; p++; } else ______; if(*r=="\0") n++; sir++; } return ______; } void main() { char str[81],suh[3]; int n; system("CLS"); printf("输入主字符串:"); gets(str); printf("输入子字符串:"); gets(sub); puts(str); puts(sub); n=proc(str,sub); printf("n=%d\n",n); }
查看答案
搜索结果不匹配?点我反馈