URI Online Judge | 1042
Simple Sort
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1
Read three integers and sort them in ascending order. After, print these values in ascending order, a blank line and then the values in the sequence as they were readed.
Input
The input contains three integer numbers.
Output
Present the output as requested above.
Input Sample | Output Sample |
7 21 -14 | -14 7 21 7 21 -14 |
-14 21 7 | -14 7 21 -14 21 7 |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int arr[100],ar[100],i;
for(i=0;i<3;i++)
{
cin>> arr[i];
ar[i]=arr[i];
}
sort(arr,arr+3);
for(i=0;i<3;i++)
{
cout<< arr[i]<<endl;
}
cout<<endl;
for(i=0;i<3;i++)
{
cout<< ar[i]<<endl;
}
}
Comments
Post a Comment