#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個贊
#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;
}
- 2 回答
- 0 關(guān)注
- 1799 瀏覽
添加回答
舉報
0/150
提交
取消