#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int x,a[1001];
string c;
while(cin>>x)
{
for(int i=0;i<x;++i)
cin>>a[i+1];
for(int i=0;i<=x;++i)
{
for(int i=2;i<=x;++i){
int t=a[i];
if(a[i]%10<a[i-1]%10 || a[i]%10==a[i-1]%10 && a[i-1]<a[i])
{
a[i]=a[i-1];
a[i-1]=t;
}
}
}
for(int i=0;i<x;++i)
cout<<a[i+1]<<" ";
cout<<endl;
}
}
Close
CPP
|