Created
November 20, 2012 11:23
-
-
Save y-yu/4117377 to your computer and use it in GitHub Desktop.
7-2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void swap_array (int a[], int i, int j) { | |
int t = a[i]; | |
a[i] = a[j]; | |
a[j] = t; | |
} | |
int main () { | |
int i; | |
int a[] = {0, 1, 2, 3, 4, 5, 6}; | |
swap_array(a, 3, 4); | |
for (i=0; i<sizeof(a)/sizeof(a[0]); i++) | |
printf("%d\n", a[i]); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment