#include <iostream>
#include <Windows.h>
using namespace std;
void Change1(int*& a, int*& b) {
    int* tmp = a;
    a = b;
    b = tmp;
}
int main() {
    int a = 6, b = 221;
    int *p = &a,  *q = &b;
    cout << "交换前:" << endl;
    cout << "p=" << p << ",q=" << q << endl;
    cout << "p所指的值:" << *p << ",q所指的指:" << *q << endl;
    Change1(p, q);
    cout << "交换后:" << endl;
    cout << "p=" << p << ",q=" << q << endl;
    cout << "p所指的值:" << *p << ",q所指的指:" << *q << endl;
}

posted on 2023-07-16 17:33  wshidaboss  阅读(8)  评论(0编辑  收藏  举报