编写函数strrindex(s,t)它将返回字符串t在s中最右边出现的位置

来源:互联网 发布:怎样成为淘宝卖家 编辑:程序博客网 时间:2024/05/17 04:00

#include<stdio.h>

int strrindex(char s[],char t[])
{
 int i,j,k,pos;
 pos=-1;
 for(i=0;s[i]!='\0';i++)
 {
  for(j=i,k=0;t[k]=='\0'&&s[j]==t[k];j++,k++)
   ;
  if(k>0 && t[k]=='\0')
   pos=i;
 }
 return pos;
}

原创粉丝点击