c8-8-2.c 498 B

12345678910111213141516171819202122232425
  1. #include <stdio.h>
  2. int main()
  3. {void inv(int *x,int n);
  4. int i,a[10]={3,7,9,11,0,6,7,5,4,2};
  5. printf("The original array:\n");
  6. for(i=0;i<10;i++)
  7. printf("%d ",a[i]);
  8. printf("\n");
  9. inv(a,10);
  10. printf("The array has been inverted:\n");
  11. for(i=0;i<10;i++)
  12. printf("%d ",a[i]);
  13. printf("\n");
  14. return 0;
  15. }
  16. void inv(int *x,int n) //ÐβÎxÊÇÖ¸Õë±äÁ¿
  17. {int temp,*i,*j;
  18. i=x;j=x+n-1;
  19. for(;i<=j;i++,j--)
  20. {temp=*i;*i=*j;*j=temp;} //*iÓë*j½»»»
  21. return;
  22. }