编函数int find(char s[],char t[]),该函数在字符串s中查找字符串t,如果找到,则返回字符串t在字符串s中的位置(整数值);否则返回-1。注意:用数组方式及两重循环来实现该函数。仅在find的花括号中填写若干句。
#include<iostream.h> #include<string> int find(char s[],char t[]); const int MAXLINE=256; int main() {char source[MAXLINE],target[MAXLINE]; cout<<"Please in put a string for searching:\n"; cin.getline(source,MAXLINE); cout<<"Please input a string you want to find:\n"; cin.getline(target,MAXLINE); int intPos=find(source,target); if(inPos>=0) cout<<"Find it.The target string is at index"<<inpos<<"of the source string\n"; else cout <<"Not finding it.\n"; return 0; } int find(char s[],char t[]) { }
试了很多次都不成功,又没有答案·········
帮帮忙········
呵呵·······