3364 - 交换变量
输入两个整数a和b,试交换a和b的值
题目输入
输入数据只有一行为两个整数,两数之间用一个空格隔开,分别是a和b的值
题目输出
输出一行,为交换后a和b的值
输入/输出样例
题目输入
12 36
题目输出
36 12
提示
题目来源:吕红波
C++解答
#include<iostream> #include<cstdio> using namespace std; int c,d; void swap(int &c,int &d); void swap(int &c,int &d) { int t; t=c; c=d; d=t; } int main() { int a,b; cin>>a>>b; swap(a,b); cout<<a<<' '<<b<<endl; return 0; }
提示
题目来源:吕红波