#include 'stdio.h'

void reverse(int a[], int start, int count) { for (int i = 0; i < count / 2; ++i) { int temp = a[start+i]; a[start+i] = a[start+count-i-1]; a[start+count-i-1] = temp; }
}

int main(){ int a[10] = {2,4,6,8,10,12,14,16,18,20}; reverse(a, 3, 5); for (int i = 0; i < 10; ++i) { printf('%d ',a[i]); } return 0; }

C语言数组逆序:从指定位置开始逆转部分元素

原文地址: https://www.cveoy.top/t/topic/npjx 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录