201306111938把陣列資料反轉

/* printf example */

 

#include <stdio.h>

#include <string.h>

void reverse_array(int arr[], int length);

void main(){

        int strarray[10] = {0x01,0x02,0x03,0x04,0x05,6,7,8,9,0x0a};

        reverse_array(strarray,10);

        printf("The array is \r\n");

 

}

void reverse_array(int arr[], int length)

{

        int i, temp;

        for (i=0; i<length/2; i++)

        {

                 temp = arr[i];

                 arr[i] = arr[length-i-1];

                 arr[length-i-1] = temp;

        }

}

沒有上一則|日誌首頁|沒有下一則
回應





Powered by Xuite
    沒有新回應!
關鍵字