/*
将字符串S2中的任一字符在字符串S1中第一次出现的位置作为结果返回,若S1中不存在该字符,则返回-1
将字符串S2中的任一字符在字符串S1中第一次出现的位置作为结果返回,若S1中不存在该字符,则返回-1
*/
#include <stdio.h>
int any(char s1[],char s2[])
{
int i,j;
for (i=0;s1[i]!='\0';i++)
{
for (j=0;s2[j]!='\0';j++)
{
if (s2[j]==s1[i])
{
return i;
}
}
}
return -1;
}
void main()
{
int index;
char s1[] = "abcdefg";
char s2[] = "cd";
index = any(s1,s2);
printf("%d\n",index);
}