惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
J
Java Code Geeks
V
V2EX
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
B
Blog
A
About on SuperTechFans
有赞技术团队
有赞技术团队
月光博客
月光博客
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
腾讯CDC
美团技术团队
大猫的无限游戏
大猫的无限游戏
爱范儿
爱范儿
N
Netflix TechBlog - Medium
C
Check Point Blog
Recent Announcements
Recent Announcements
博客园 - Franky
博客园 - 叶小钗
T
Tailwind CSS Blog

博客园 - Jeff

4个月 C++ 有限状态机 POJ1019 POJ1035 POJ1005 ONLINE_JUDGE Linux shell定时器 怪异的grep结果 URL2FILE C primer笔记 Vxworks增加system call C语言常用宏定义技巧 分苹果 Socket 为什么选择SMP而不是AMP RTP memory in Vxworks Windriver的项目类型 RTP affinity Symmetric multiprocessing (SMP)
POJ1007
Jeff · 2012-01-05 · via 博客园 - Jeff

2012-01-05 15:03  Jeff  阅读(538)  评论()    收藏  举报

#include "stdio.h"
int main(void) {
    int num;
    int length;
    char str_out[100][51];
    int index;
    int index1;
    int result[100];
    int a=0;
    int b=0;
    int min=0;
    int num2=0;
    int temp;
    int min_index;
    #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    #else
    #endif

    scanf("%d%d",&length,&num);
    num2=num;
    temp=num2;
    while(num>0){
        scanf("%s", str_out[a]);
        if(num2 == 1){
           printf("%sn",str_out[a]);
           return 0;
        }
        result[a] = 0;
        for(index=0;index<length-1;index++){
            if(str_out[a][index] == 'A')continue;
            else{
               for(index1=index+1;index1<=length-1;index1++){
                   if(str_out[a][index] > str_out[a][index1])result[a]++;
               }
            }

        }
    num--;
    a++;
    }
    while(num2>0){
    if(result[b]==5000)
    {
        b++;
        continue;
    }
    min = result[b];
    min_index = b;

    for(index=0;index<temp-1;index++){
        if(min > result[index+1]){
           min = result[index+1];
           min_index =index+1;
        }
    }
    result[min_index] = 5000;
    num2--;
    printf("%sn",str_out[min_index]);
    min_index = 0;
}
    #ifndef ONLINE_JUDGE
    fclose(stdin);
    #else
    #endif
    return 0;