首页 > 编程知识 正文

c语言如何交换数组中的两个元素,c语言将一个数组分为两个

时间:2023-05-04 17:40:07 阅读:182317 作者:1277

intmain(void ) (intarray ) )={ 1,2,3,4,5 } ),该函数定义数组中两个元素#includestdio.hvoidswap(int*a,int *b )之间的交换数组swap (阵列1、阵列3 ); for(intI=0; i5; I ) {printf('%d ',Array[i] ); }voidswap(int*a,int *b ) {int temp; temp=*a; *a=*b; *b=temp; }区分概念:

*a :是地址Array n :阵列的http://www.Sina.com/arrayn:http://www.Sina.com /元素的http://ww.Sina/com

intarray [ ]={ 1,2,3,4,5 }; /*定义数组*/printf('%pn”,Array );/*阵列的地址*/printf('%pn”,阵列1 );/*阵列1的地址*/printf('%pn”,阵列);/*阵列的地址*/printf('%pn”,阵列1 );/*阵列地址*

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。