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

为什么一直OLE啊?

Posted by Maycode at 2009-03-29 16:07:02 on Problem 1007
#include<iostream>
#include<string>

using namespace std;
const int M = 100;
const int N = 50;
char s[M][N];
int a[M];
bool b[M];

int main()
{
    int i,j,k,n,m,temp=0;
    memset(a,0,sizeof(a));
    cin>>n>>m;
    for(i=0;i<m;i++)
        cin>>s[i];

    for(i=0;i<m;i++)
    {
         temp=0; 
         for(j=0;j<n-1;j++)
         {
        
            for(k=j+1;k<n;k++)
            {
                if(s[i][j]>s[i][k])
                {
                   temp++;            
                }             
            }
        
               
         }    
    a[i]+=temp;      
    }

    for(i=0;i<m;i++)
    {
         temp=0;
         int min=999999999;
         for(j=0;j<m;j++)
         {
            if(a[j]<min&&b[j]==0)
            {
                min=a[j];
                temp=j;          
            }
                      
         }
         if(i!=m-1)
         cout<<s[temp]<<endl;
         else 
         {
            cout<<s[temp]<<endl;
            //system("pause");
            return 0;  
         }
         
         b[temp]=1;
          
              
    }

 
}

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