函数题:
6-1 查找子串:
裁判测试程序样例:
#include <stdio.h>
#define MAXS 30
char *search(char *s, char *t);
void ReadString( char s[] ); /* 裁判提供,细节不表 */
int main()
{
char s[MAXS], t[MAXS], *pos;
ReadString(s);
ReadString(t);
pos = search(s, t);
if ( pos != NULL )
printf("%d
", pos - s);
else
printf("-1
");
return 0;
}
/* 你的代码将被嵌在这里 */
输入样例1:
The C Programming Language
ram
输出样例1:
10
输入样例2:
The C Programming Language
bored
输出样例:
-1
代码:
char *search(char *s, char *t)
{
int i=0,j=1;
while(s[i]!='