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 |
为什么wa阿?sample input测试下来是正确的阿。。。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator