指针练习4

xiaoxiao2021-02-28  89

//编写一个通用函数,该函数实现对数值类型数组的倒序 #include <stdio.h> #define N 6 int fun(int *p,int n) {     int temp;     int *i=p;     int *j=p+n-1;     while(j>i)     {         temp=*i;         *i=*j;         *j=temp;         i++;         j--;     }     return 0; } void main() {     int i=0;     int str[N]={0,1,2,3,4,5};     for(i=0;i<N;i++)     {         printf("%d",str[i]);     }     printf("\n");     fun(str,N);     for(i=0;i<N;i++)     {         printf("%d",str[i]);     } }
转载请注明原文地址: https://www.6miu.com/read-42832.html

最新回复(0)