# include <stdio.h>
int find_substr(char* s1, char* s2);
void main()
{
if(find_substr("C is fun", "is") != -1)
printf("Substring is found.\n");
}
int find_substr(char* s1, char* s2)
{
register int t;
char *p, *p2;
for(t=0; s1[t]; t++)
{
p = &s1[t];
p2 = s2;
while(*p2 && *p2==*p)
{
p++;
p2++;
}
if(! *p2)
return t;
}
return -1;
}
第二个
# include <stdio.h>
void convert(int n)
{
int i;
if((i=n/10) != 0)
convert(i);
putchar(n%10+'0');
}
void main()
{
int number;
printf("输入整数:");
scanf("%d", &number);
printf("输出是:");
if(number < 0)
{
putchar('-');
number = -number;
}
convert(number);
putchar('\n');
}