第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

函數(shù)參數(shù),為什么第一次執(zhí)行swap函數(shù)換了值卻沒執(zhí)行函數(shù)swap中的打印

函數(shù)參數(shù),為什么第一次執(zhí)行swap函數(shù)換了值卻沒執(zhí)行函數(shù)swap中的打印

C++
ReZero 2016-03-05 11:12:41
#include<cstdio>#include<iostream>using namespace std;int swap(int *a, int *b){? ? int t = *a;? ? *a = *b;? ? *b = t;? ? cout<<*a<<":"<<*b<<endl;}int main(){? ? int x1, y1;? ? cin>>x1>>y1;? ? swap(x1, y1);? ? cout<<x1<<" "<<y1<<endl;? ? int x2, y2;? ? cin>>x2>>y2;? ? swap(&x2, &y2);? ? cout<<x2<<" "<<y2<<endl;}
查看完整描述

2 回答

?
流浪_老

TA貢獻(xiàn)71條經(jīng)驗 獲得超14個贊

你第一次調(diào)用的時候沒有加&符號哦

查看完整回答
1 反對 回復(fù) 2016-03-05
?
流浪_老

TA貢獻(xiàn)71條經(jīng)驗 獲得超14個贊

#include<cstdio>

#include<iostream>

using namespace std;

void swap(int *a, int *b){

? ? int t = *a;

? ? *a = *b;

? ? *b = t;

? ? cout<<*a<<":"<<*b<<endl;

}

int main()

{

? ? int x1, y1;

? ? cin>>x1>>y1;

? ? swap(&x1, &y1);

? ? cout<<x1<<" "<<y1<<endl;


? ? int x2, y2;

? ? cin>>x2>>y2;

? ? swap(&x2, &y2);

? ? cout<<x2<<" "<<y2<<endl;

}


查看完整回答
1 反對 回復(fù) 2016-03-05
  • 2 回答
  • 0 關(guān)注
  • 1799 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號