swap

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 
 4 void swap (int *a, int *b);
 5 int main()
 6 {
 7     int a = 3;
 8     int b = 5;
 9 
10     swap(&a, &b);
11 
12     printf("a = %d, b = %d", a, b);
13 
14     return 0;
15 }
16 
17 void swap(int *a, int *b)
18 {
19     int c;
20     c = *a;
21     *a = *b;
22     *b = c;
23 }

 

posted @ 2020-02-28 14:37  张乐珊  阅读(233)  评论(0)    收藏  举报