UVA10815
来源:互联网 发布:天天向上的网络作家 编辑:程序博客网 时间:2024/05/22 15:49
把一段话里所有单词分离出来,并字典序排序。不区分大小写。
用个qsort就好了。
AC代码如下:
#include <stdio.h>#include <ctype.h>#include <string.h>#include <stdlib.h>#define len 5001#define le 201char s[len*le][le];int icmp(const void *a,const void *b){return strcmp((char *)a,(char *)b);}int main(void){int i=0,j=0;char ch;while((ch=getchar())!=EOF){ if(isalpha(ch)) s[i][j++]=tolower(ch); if(!isalpha(ch)&&isalpha(s[i][0])) { s[i++][j]='\0'; j=0; }}qsort(s,i,sizeof(s[0]),icmp);for(j=1,puts(s[0]);j<i;j++)if(strcmp(s[j-1],s[j]))puts(s[j]);return 0;}
0 0
- uva10815
- UVA10815
- uva10815
- UVA10815
- uva10815
- uva10815
- UVA10815
- uva10815
- UVA10815
- UVa10815
- Uva10815
- ACM-uva10815
- uva10815--没过
- uva10815 分离字符串
- set 集合 uva10815
- uva10815 - Andy's First Dictionary
- UVA10815 Andy's First Dictionary
- UVa10815 - Andy's First Dictionary
- POJ 1061 青蛙的约会
- 阶梯一:2014/7/23 静态函数和普通函数的区别
- 【solr专题之二】配置文件:solr.xml solrConfig.xml schema.xml
- Inheritance
- android中wifi原理及流程分析(很经典)
- UVA10815
- n个数的全排列
- android 获取应用程序包名,图标,入口Activity类
- OpenCV轮廓提取
- Codeforces Round #257 (Div. 2) E题:Jzzhu and Apples 模拟
- jquery包装集, jquery对象与js对象转换
- openwrt单独编译bluez软件包
- python中的正则表达式
- Android安装应用后点击"打开"(Open)带来的问题及解决方式