Toggle navigation
Home
Latest pastes
FAQ
Random
Register
Login
Untitled
SUBMITTED BY:
Guest
DATE:
March 4, 2015, 7:10 a.m.
FORMAT:
Text only
SIZE:
1.1 kB
Raw
Download
Tweet
HITS:
721
Go to comments
Report
/*
BEGIN swap(num1, num2)
SET tmp to num1
SET num1 to num2
SET num2 to tmp
END swap
if (num[0] > num[1]) swap(num[0], num[1]);
if (num[0] > num[2]) swap(num[0], num[2]);
if (num[1] > num[2]) swap(num[1], num[2]);
BEGIN sort
READ num1
READ num2
READ num3
IF num1 > num2 THEN
CALL swap(num1, num2)
ENDIF
IF num1 > num3 THEN
CALL swap(num1, num3)
ENDIF
IF num2 > num3 THEN
CALL swap(num2, num3)
ENDIF
END sort
*/
#include <iostream>
using namespace std;
inline void swap(int& a, int&b)
{
int tmp = a;
a = b;
b = tmp;
}
int main()
{
int num[3];
std::cin >> num[0] >> num[1] >> num[2];
if (num[0] > num[1])
swap(num[0], num[1]);
if (num[0] > num[2])
swap(num[0], num[2]);
if (num[1] > num[2])
swap(num[1], num[2]);
std::cout << num[0] << num[1] << num[2] << '\n';
std::cin.get();
return 0;
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus