【Eternallyc】实现两个数交换

来源:互联网 发布:php __set 破坏封装 编辑:程序博客网 时间:2024/05/16 15:07

通过传两个变量的地址来实现

#include <cstdio>void swip(int *a,int *b){    int temp;    temp=*a;    *a=*b;    *b=temp;}int main(){    int a,b;    scanf("%d%d",&a,&b);    swip(&a,&b);    printf("%d %d",a,b);    return 0;}