*和&

来源:互联网 发布:大数据的特征是什么 编辑:程序博客网 时间:2024/03/28 23:12
void exchange(int &a,int &b)
{
    int temp;
    temp = a;
    a = b;
    b = temp;
}

void change(int *a,int *b)
{
//    int *temp;
//    temp = a;
//    a = b;
//    b = temp;

    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}


int main()
{
    int i,j;
    i = 5;
    j = 8;
    exchange(i,j);
    cout<<i<<j<<endl;

    int *p1,*p2;
    int m,n;
    p1 = &m;
    p2 = &n;
    m = 3;
    n = 9;

    change(p1,p2);
    cout<<m<<n<<endl;
    return 0;
}
0 0
原创粉丝点击