码迷,mamicode.com
首页 > 其他好文 > 详细

uva 10815 - Andy's First Dictionary

时间:2015-07-16 19:20:27      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:

#include<iostream>
#include<cctype>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;

char word[5001*201][201];

int cmp(const void *a,const void *b){
    return strcmp((char*)a , (char *)b);
}

int main(){
    char ch;
    int i = 0,j = 0;
    while((ch = getchar()) != EOF){
        if(isalpha(ch)){
            word[i][j++] = tolower(ch);
        }
        if(!isalpha(ch) && isalpha(word[i][0])){     //控制条件比较精妙
            word[i++][j] = ‘\0‘;
            j = 0;
        }
    }
    qsort(word,i,sizeof(word[0]),cmp);
    puts(word[0]);
    for(int k = 1; k < i; k++){
        if(strcmp(word[k-1],word[k]))
            puts(word[k]);
    }

    return 0;
}

 

uva 10815 - Andy's First Dictionary

标签:

原文地址:http://www.cnblogs.com/yong-hua/p/4651954.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!