| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
完全没有思想的模拟法。。。。求同类!!#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
using namespace std;
int cmp ( char a , char b )
{
return a<b;
}
int main()
{
int i,j,n;
char a[500];
char b;
while( cin>>a)
{
int kk=0;
sort(a,a+strlen(a),cmp);kk++;
cout<<a<<endl;
int k=strlen(a)-1;
int k1=k;
int k2=k1;
while(1)
{
int pp=0;
k1=k;
while(k1>0)
{
for(i=k1;i>=0;i--)
{
for(j=k1;j>=i;j--)
{
if(a[i]<a[j])
{
b=a[i];
a[i]=a[j];
a[j]=b;
pp=1;
break;
}
}
if(pp==1) break;
}
if(pp==1) break;
else k1--;
}
//cout<<"L"<<endl;
if(pp==0) break;
for(j=i+1;j<=k;j++)
{
for(int p=j;p<=k;p++)
{
if(a[j]>a[p])
{
b=a[j];
a[j]=a[p];
a[p]=b;
}
}
}
cout<<a<<endl;
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator