c++实验 引用与指针

#include

using namespace std;

void swap(int& a, int& b){
    int tmp;
    tmp = a;
    a = b;
    b = tmp;
}

void swap(int* a, int* b){
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int main(){
    int a=9;
    int b=10;
    cout<<"a:"<     swap(a, b);
    cout<<"a:"<     swap(&a, &b);
    cout<<"a:"<     
    return 0;
}

你可能感兴趣的:(c++,算法,数据结构)