Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

ac

Posted by zfeagle at 2012-08-31 20:23:36 on Problem 1007
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct node
{
    int a;
    char s[1000];       
}p[1000];
int cmp(node c,node b)
{
    return c.a<b.a;
}
int main()
{
     int m,n;
     while(~scanf("%d%d",&n,&m))
     {
          for(int i=0;i<1000;i++)
          p[i].a=0;
          for(int i=0;i<m;i++)
          scanf("%s",p[i].s); 
          for(int k=0;k<m;k++)
          for(int i=0;i<n;i++)
              for(int j=i+1;j<n;j++)
              if(p[k].s[i]>p[k].s[j])
              p[k].a++;           
          sort(p,p+m,cmp);                    
     for(int i=0;i<m;i++)
     printf("%s\n",p[i].s);
     }    
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator