编写一个C++风格的程序,输入两个整数,将它们从小到大的顺序输出,要求使用变量的引用,谢谢

如题所述

#include <stdio.h>
#include<iostream>
using namespace std;
void swap(int &a,int &b)
{
int tmp=0;
if(a>b)
{
tmp=a;
a=b;
b=tmp;
}
}
int main()
{
int a,b;
cin>>a>>b;
swap(a,b);
cout<<a<<" "<<b<<endl;

return 0;
}追问

#include
using namespace std;
int &swap(int &a,int &b)
{

}
这样什么问题吗?
谢谢

温馨提示:答案为网友推荐,仅供参考
相似回答