作者 GONG
单位 哈尔滨华德学院
编写函数实现三个整数升序排列,并使该函数符合以下主函数的调用要求。
注意:输入输出均在主函数中完成。
###接口定义:
void Sort(int &a, int &b, int &c);
主函数:
#include <iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
Sort(a,b,c);
cout<<a<<" "<<b<<" "<<c<<endl;
return 0;
}
输入样例:
21 2 5
输出样例:
2 5 21
参考示例:
#include<bits/stdc++.h>
using namespace std;
void Sort(int &a,int &b,int &c){
int s[]={a,b,c};
sort(s,s+3);
a=s[0],b=s[1],c=s[2];
}

132

被折叠的 条评论
为什么被折叠?



