码迷,mamicode.com
首页 > 编程语言 > 详细

两个C++程序

时间:2018-03-18 21:45:38      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:日常

#include<iostream>
using namespace std;
int main()
{void sort(int x,int y,int z);
int x,y,z;
cin>>x>>y>>z;
sort(x,y,z);
return 0;
}
void sort(int x,int y,int z)
{int temp;
if(x>y)
{temp=x;
x=y;
y=temp;
}
if(x<y)
cout<<z<<‘,‘<<x<<‘,‘<<y<<endl;
else if(z<x)
cout<<x<<‘,‘<<z<<‘,‘<<y<<‘,‘<<endl;
else if(z<y)
cout<<x<<‘,‘<<z<<‘,‘<<y<<‘,‘<<endl;
else
cout<<x<<‘,‘<<y<<‘,‘<<z<<‘,‘<<endl;
}技术分享图片
#include<iostream>
using namespace std;
int main()
{int a,b,c,temp;
cin>>a>>b>>c;
int &ra=a;
int &rb=b;
int &rc=c;
if(ra>rb)
{temp=ra;
ra=rb;
rb=temp;
}
if(ra>rc)
{temp=ra;
ra=rc;
rc=temp;
}
if(rb>rc)
{temp=rb;
rb=rc;
rc=temp;
}
cout<<a<<‘,‘<<b<<‘,‘<<c<<‘,‘<<endl;
return 0;
}技术分享图片

两个C++程序

标签:日常

原文地址:http://blog.51cto.com/13615683/2088262

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!