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

为什么wa阿?sample input测试下来是正确的阿。。。

Posted by strideryu at 2009-03-02 21:06:31 on Problem 1007
#include<iostream>
using namespace std;
int inver_num(char* s,int m);
struct DNA{
       int inv_n;
       char result[50];
       };
int main()
{
    int n,m;
    cin>>n>>m;
    DNA dna_str[m],temper;
    int i;
    for(i=0;i<m;i++){
                     cin>>dna_str[i].result;
                     dna_str[i].inv_n=inver_num(dna_str[i].result,n);
                     }                 
 
    int j,k,l;
    j=m;
    for(;j>1;j--)
       for(l=0;l<j;l++)
          if(dna_str[l].inv_n>dna_str[l+1].inv_n){
             temper=dna_str[l+1];
             dna_str[l+1]=dna_str[l];
             dna_str[l]=temper;
             }                       

    for(l=0;l<m;l++)cout<<dna_str[l].result<<endl;
    return 0;
}
//-----------------------------------------------------
int inver_num(char* s,int m)
{
int i,j,inv_counter=0;
for(i=0;i<m-1;i++)
   for(j=i+1;j<m;j++){
      if(s[i]>s[j])inv_counter++;
      }
return inv_counter;
}

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