程序代码:
#include<iostream>
#include<string>
using namespace std;
void main()
{
string s="ack",s1="bgr";
string s2=s+s1;
int n=s2.size(),i,j,t;
for(i=0;i!=n;i++)
for(j=n-1;j!=i;j--)
{
if(s2[j]<s2[j-1])
{t=s2[j];
s2[j]=s2[j-1];
s2[j-1]=t;}
}
cout<<s2<<endl;
}