输入两数a,b,交换值后输出
#include <stdio.h> void swap(int *pa, int *pb) { int t; t = *pa; *pa = *pb; *pb = t; } int main() { int a, b; printf("input two numbers: "); scanf("%d", &a); scanf("%d", &b); swap(&a, &b); printf("a=%d, b=%d ", a, b); return 0; }
输入两数a,b,交换值后输出
#include <stdio.h> void swap(int *pa, int *pb) { int t; t = *pa; *pa = *pb; *pb = t; } int main() { int a, b; printf("input two numbers: "); scanf("%d", &a); scanf("%d", &b); swap(&a, &b); printf("a=%d, b=%d ", a, b); return 0; }