题目描述 问题描述 编写函数 int locStr(char *str1 ,char *str2)实现字符串匹配的定位功能;若字符串 str1 中含有字符串 str2,则返回字符串 str2 在字符串 str1 中的位置,否则返回-1; 算法设计 使用循环结构进行设计即可,注意题目中已给出了函数的形参,所以使用数组进行参数传递较为方便。 C++代码 #include<iostream> using namespace std; /*因为题目中给出了函数,所以不能用string,使用数组较为方便*/