求C语言程序 12点之前

来源:百度知道 编辑:UC知道 时间:2024/07/02 23:48:57
将给定的字符串以词为单位倒序,同时给定一个子串,若字符串中有部分内容与子串相同则该部分不倒序。
例: 给定字符串"The quick brown fox jumps over the lazy dog"和子串"brown fox", 倒序结果是"dog lazy the over jumps brown fox quick The"

#include"stdio.h"
#include"conio.h"
#include"string.h"
#define N 50
main()
{
char a[N],b[N];
int i,l,t;
printf("请输入两个字符串(b为子字符串):\n");
gets(a);
gets(b);
i=strcmp(a,b);
if(i!=0)
{
l=strlen(a)-1;
for(i=0;i<strlen(a)/2;i++,l--)
{ t=a[i];
a[i]=a[l];
a[l]=t;
}
}
printf("%s",a);
getch();
}
如果还有问题,发短信给我....