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 |
Why#include "iostream" #include "string" using namespace std; int len,n; void test(string s,int &e) { int i,j; for(i=0;i<len;i++) for(j=i+1;j<len;j++) if(s[i]>s[j]) e++; } int main() { int i,j; int *a; string *p; char *c; cin>>len>>n; a=new int[n]; c=new char[len]; p=new string[n]; for(i=0;i<n;i++) { cin>>c; p[i]=c; a[i]=0; test(p[i],a[i]); } for(j=1;j<=len*(len+1)/2;j++) for(i=0;i<n;i++) if(a[i]==j) cout<<p[i]<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator