- #include <stdio.h>
- #define NUM_I 10
- #define NUM_A 30
- int any(char s1[], char s2[]);
- int main()
- {
- char s1[NUM_A];
- char s2[NUM_I];
- int i;
- printf("please input s1:\\n");
- scanf("%s", s1);
- printf("please input s2:\\n");
- scanf("%s", s2);
- i = any(s1, s2);
- printf("s1 = %s \\ns2 = %s \\n", s1, s2);
- printf("any = %d \\n", i) ;
- return 0;
- }//end main
- int any(char s1[], char s2[])
- {
- int i, j;
- for (i = 0; s1[i] != '\\0'; i++ )
- {
- for (j = 0; s2[j] != '\\0'; j++)
- {
- if (s1[i] == s2[j])
- return i + 1 ;
- }
- }
- return -1;
- }
- //该片段来自于http://www.codesnippet.cn/detail/210120148587.html
来源: http://www.codesnippet.cn/detail/210120148587.html