下面这个程序哪里出错了
#include <stdio.h>void exchange(int *x, int *y, int n)
{
int z ,i;
for (i=1; i<=n; i++)
{
z=*(x+i);
*(x+i)=*(y+i);
*(y+i)=z;
}
}
int main ()
{
int a[]={0}, b[]={0} ,n ,i, *p1,*p2;
printf ("输入数组个数n\n");
scanf ("%d",&n);
printf("请输入数组a的所有值\n");
for (i=1; i<=n ; i++)
{
scanf ("%d",&a[i]);
p1=&a[i];
p1++;
}
printf ("请输入数组b的所有值\n");
for (i=1; i<=n ; i++)
{
scanf ("%d",&b[i]);
p2=&b[i];
p2++;
}
exchange(p1, p2,n );
printf ("交换后a的值为:");
for (i=1; i<=n ;i++)
printf ("%d",a[i]);
printf("\n");
printf("交换后b的值为:\n");
for (i=1; i<=n ; i++);
printf ("%d",b[i]);
printf ("\n");
}