首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

大家帮忙看看如何实现iFind(string *source,string *find)

2012-03-05 
大家帮忙看看怎么实现iFind(string *source,string *find)#includeiostream.h//要求输出find在source中

大家帮忙看看怎么实现iFind(string *source,string *find)
#include   <iostream.h>

//要求输出find在source中从右往左第一次出现的位置,没有找到输出-1
//其中source和find第一个元素的位置是0
//如   ifind   ( "abccbad ", "ba ")       输出4
//       ifind   ( "abbccbce ", 'bc ")     输出5
//       ifind   ( "bacab ", "de ")           输出-1
int   iFind(string   *source,string   *find)
{

}

void   main   ()
{
int   a   =   0;
a   =   ifind( "abbcadededde ", "ed ");
cout < <a;
}


[解决办法]
string* ?还是char*?
int iFind(char *source,char *find)
{
return strstr(source, find)-source;
}

热点排行