UVA 11462 - Age Sort Solution
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<cstdio>
using namespace std;
long long array[2000000];
int main()
{
long long i,n;
while(cin>>n)
{
if(n==0) break;
for(i=0; i<n; i++)
{
cin>>array[i];
}
sort(array, array + n);
for(i=0; i<n-1; i++)
{
cout<<array[i]<<" ";
}
cout<<array[n-1]<<endl;
}
return 0;
}
Problem Link : https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2457
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<cstdio>
using namespace std;
long long array[2000000];
int main()
{
long long i,n;
while(cin>>n)
{
if(n==0) break;
for(i=0; i<n; i++)
{
cin>>array[i];
}
sort(array, array + n);
for(i=0; i<n-1; i++)
{
cout<<array[i]<<" ";
}
cout<<array[n-1]<<endl;
}
return 0;
}
Problem Link : https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2457
No comments:
Post a Comment
Thank you for commenting. Please wait for response :)