3168. 查找字符串

Easy函数字符串

时间限制:2000 ms

内存限制:256 MiB

题面

定义一个函数 strReverseIndex(s,t)strReverseIndex(s,t),返回 ttss 中最右边出现的位置(ss 中的第 11 个字符的位置为 00),找不到时返回-1

//********** Specification of strrindex**********
int strReverseIndex(char s[],char t[ ]);
/* precondition: NULL
postcondition: return index of t in s from right  to left, -1 if none
*/

只需按要求写出函数定义,并使用给定的测试程序测试你所定义函数的正确性。不要改动测试程序。测试正确后,将测试程序和函数定义一起提交。

/***************************************************************/
/*                                                             */
/*  DON'T MODIFY main function ANYWAY!                         */
/*                                                             */
/***************************************************************/
#include <stdio.h>
int strReverseIndex(char s[],char t[])
/* precondition: NULL
postcondition: return index of t in s from right to left, -1 if none
*/
{
	//TODO: your function definition
}
/***************************************************************/
#define N 80
int main()
{
	char s[N+1],t[N+1];
	scanf("%s%s",s,t);
	//********** strReverseIndex is called here ********************
	printf("%d\n",strReverseIndex(s,t));
	//**************************************************
	return 0;
}