查找数组中某个元素出现的最后一个位置,怎么写这个方法?

类似于lastIndexOf这个方法 返回所要查找的元素在数组中出现的最后一个位置,如何没找到返回-1
char[] ch = {'a','v','a','e'};
public int lastIndexOf(char c) 需要返回a字母出现的最后一个位置 2
麻烦帮忙实现以下这个方法,谢谢了。 最好用java语言。。。

#include<stdio.h>
#include<string.h>
int i,n=0,len;
char s[101],t[101],*p;
int lastIndexOf(char c)
{
_strrev(s);
len=strlen(s);
if((p=strstr(s,t)))
{
n=p-s;
return len-n-1;
}
return 0;
}
int main()
{
while(scanf("%s%s",s,t)==2)
printf("%d\n",lastIndexOf(t[0]));
}
温馨提示:答案为网友推荐,仅供参考