指针方法的数据交换

来源:互联网 发布:3d照相软件 编辑:程序博客网 时间:2024/05/16 08:14
#include<iostream>using namespace std;void swap(int*p1, int* p2);int main(){int a, b;int*pp1, *pp2;cin >> a >> b;pp1 = &a;pp2 = &b;swap(pp1, pp2);cout << a << b << endl;system("pause");return 0;}void swap(int*p1, int*p2){int temp;temp = *p1;*p1 = *p2;*p2 = temp;}

0 0
原创粉丝点击