0
点赞
收藏
分享

微信扫一扫

指针实现数组逆置

桑二小姐 2022-03-14 阅读 37
#include <stdio.h>
#define N 10
int main()
{
	/********** Begin **********/
  int a[10],*i,*j,temp;
  for(int m=0;m<10;m++) 
  {
    scanf("%d",&a[m]);
  }
i = &a[0];                  
j = &a[9]; 
while(i<=j)                
{
  temp = *i; *i = *j; *j=temp; 
i++;                         
j--;       
} 
for(int m=0;m<10;m++)
{printf("%d ",a[m]); } 
    /********** End **********/
   return 0;
 }
1 2 3 4 5 6 7 8 9 10
10 9 8 7 6 5 4 3 2 1
--------------------------------
Process exited after 8.95 seconds with return value 0
请按任意键继续. . .
举报

相关推荐

0 条评论