#include <stdio.h>
#include <string.h>
/*从字符串右边的strindex函数*/
int strindex(char s[], char t[]);
int main()
{
printf("%d\n", strindex("1index", "ind"));
return 0;
}
int strindex(char s[], char t[])
{
int i, j, k;
for(i = strlen(s) - strlen(t), k = 0; i >= 0; i--)
{
for(j = i; s[j] == t[k] && t[k] != '\0'; j++, k++)
;
if(t[k]=='\0' && k > 0)
return i;
}
return -1;
}
右序strindex函数
最新推荐文章于 2024-03-22 10:52:32 发布