#include<stdio.h>#include<string.h>voidfun(char*w,intm){chars,*p1,*p2;p1=w;p2=w+m-1;while(p1<p2){s=*p1++;*p1=*p2--;*p2=s;}}main(){chara[]="ABCDEFG";fun(a,strlen(a));puts(... #include<stdio.h>
#include<string.h>
void fun (char*w,int m)
{char s,*p1,*p2;
p1=w;p2=w+m-1;
while(p1<p2)
{s=*p1++;*p1=*p2--;*p2=s;}
}
main()
{char a[]="ABCDEFG";
fun(a,strlen(a));puts(a);
}
答案是AGAAGAG,求详细解答
不明白第一次循环后p1指向a[1]且等于G,p2指向a[5],且等于A,那此时p1小于p2不就不成立了吗,循环不就结束了?