1007p

直接模拟

Code:
  1. //============================================================================   
  2. // Name        : 1007.cpp   
  3. // Author      : kevin   
  4. // Version     :   
  5. // Copyright   : copyright @ kevin   
  6. // Description : Hello World in C++, Ansi-style   
  7. //============================================================================   
  8.   
  9. #include <iostream>   
  10. #include<string>   
  11. #include<algorithm>   
  12. using namespace std;   
  13. typedef struct{   
  14.     string s;   
  15.     int count;   
  16. }DNA;   
  17. int measure(string s,int no){   
  18.     int count=0;   
  19.     for(int i=0;i<no-1;i++){   
  20.         if(s[i]=='A')   
  21.             continue;   
  22.         for(int j=i+1;j<no;j++){   
  23.             if(s[i]>s[j])   
  24.                 count++;   
  25.         }   
  26.     }   
  27.     return count;   
  28. }   
  29. bool cmp(DNA dna1,DNA dna2){   
  30.     return dna1.count<dna2.count;   
  31. }   
  32. int main() {   
  33.     const int MAX=600;   
  34.     int no,line;   
  35.     DNA dna[MAX];   
  36.     cin>>no>>line;   
  37.     for(int i=0;i<line;i++){   
  38.         cin>>dna[i].s;   
  39.         dna[i].count=measure(dna[i].s,no);   
  40.     }   
  41.     sort(dna,dna+line,cmp);   
  42.     for(int i=0;i<line;i++){   
  43.         cout<<dna[i].s<<endl;   
  44.     }   
  45.     return 0;   
  46. }   

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值