问答题
使用VC6打开考生文件夹下的源程序文件modi2.cpp。请完成函数fun(char*s1,char*s2),此函数的功能是计算s1中出现s2的个数,当不出现时,则返回0。如: s1为“1 1 12223333aaaaeeffd” s2为“11”则返回1 s2为“aa”则返回2注意:请勿改动主函数main与其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。#inClude<iOStream.h>//注意只能使用int类型,不能类型转换int fun(char*s1,char*s2){}Void main(){ char S1[1 02 4]; char S2[2 5 6]; cout<<“please input a string:”<<end1; cin.getline(S 1,1 02 4); cout<<“please input otherstring:”<<end1; cin.getline(S2,2 5 6); cout<<fun(S1,S2); cout<<end1; return;}
【参考答案】
正确答案:int Size=0; //初始化字符串 统计变量个数 int Sllen; int S2len; for(s......
(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)