/*
* .::::.
* .::::::::.
* :::::::::::
* ..:::::::::::'
* '::::::::::::'
* .::::::::::
* '::::::::::::::..
* ..::::::::::::.
* ``::::::::::::::::
* ::::``:::::::::' .:::.
* ::::' ':::::' .::::::::.
* .::::' :::: .:::::::'::::.
* .:::' ::::: .:::::::::' ':::::.
* .::' :::::.:::::::::' ':::::.
* .::' ::::::::::::::' ``::::.
* ...::: ::::::::::::' ``::.
* ````':. ':::::::::' ::::..
* '.:::::' ':'````..
*/
#include <stdio.h>
#include <stdlib.h>
void reverse(int *arr,int size){
for(int i = 0;i < size/2;i++){
int temp = arr[i];
arr[i] = arr[size-i-1];
arr[size-i-1] = temp;
}
}
int main(){
int arr[] = {1,2,3,4,5,6,7,8,9,10};
int size = sizeof(arr)/sizeof(int);
reverse(arr,size);
for(int i = 0;i < size;i++){
printf("%d\t",arr[i]);
}
system("pause");
return 0;
}
C语言反转数组
最新推荐文章于 2024-06-01 19:31:58 发布