一道简单的C语言编程题,高手请进!在线等!!!

2024-11-27 15:41:44
推荐回答(1个)
回答1:

#include"stdio.h"
#include"string.h"
int strend(char s1[50],char s2[50]);
void main()
{
char st1[50],st2[50];
printf("please input a string:");
scanf("%s",st1);
printf("please input a short string:");
scanf("%s",st2);
printf("%d",strend(st1,st2));
}
int strend(char s1[50],char s2[50])
{
char *p1,*p2;
int m,i;
m=strlen(s2);
p1=s1;
p2=s2;
while(*p2!='\0')
p2++;
p2--;
while(*p1!='\0')
p1++;
p1--;
for(i=1;i<=m;i++)
if(*p1!=*p2)
return 0;
else
{
p1--;
p2--;
}
return 1;
}