c语言数组逆置
作者:互联网
#include<stdio.h>
int main()
{
int arr[]= {1,2,3,4,5,6,7};
int tmp,i;
int left=0,right=sizeof(arr)/sizeof(arr[0])-1;
int n=right;
while(left<right)
{
tmp=arr[left];
arr[left]=arr[right];
arr[right]=tmp;
left++;
right--;
}
for(i=0; i<=n; i++)
printf("%d ",arr[i]);
return 0;
}
标签:tmp,arr,right,语言,int,数组,sizeof,逆置,left 来源: https://blog.csdn.net/weixin_44876693/article/details/122505801