#include <iostream>
#define max 1000
using namespace std;
class name
{
private:
int n,tm,p;
char a[max];
char b[max];
public:
void member(int k);
void output();
};
void name::member(int k)
{
n=k;
for(int i=0;i<n;i++)
cin>>a[i];
b[0]=a[0];
for(int j=1;j<n;j++)
{
tm=a[j]-48;
p=j-1;
while((tm<(b[p]-48))&&(p>=0))
{
b[p+1]=b[p];
p=p-1;
}
b[p+1]=tm+48;
}
}
void name::output()
{
for(int i=0;i<n;i++)
cout<<b[i]<<" ";
cout<<endl;
}
int main()
{
int m;
name ob;
while(cin>>m)
{
ob.member(m);
ob.output();
}
return 0;
}
#define max 1000
using namespace std;
class name
{
private:
int n,tm,p;
char a[max];
char b[max];
public:
void member(int k);
void output();
};
void name::member(int k)
{
n=k;
for(int i=0;i<n;i++)
cin>>a[i];
b[0]=a[0];
for(int j=1;j<n;j++)
{
tm=a[j]-48;
p=j-1;
while((tm<(b[p]-48))&&(p>=0))
{
b[p+1]=b[p];
p=p-1;
}
b[p+1]=tm+48;
}
}
void name::output()
{
for(int i=0;i<n;i++)
cout<<b[i]<<" ";
cout<<endl;
}
int main()
{
int m;
name ob;
while(cin>>m)
{
ob.member(m);
ob.output();
}
return 0;
}
No comments:
Post a Comment