HDOJ 2564:词组缩写 标志位的用处很大呀
来源:互联网 发布:淘宝网品牌女鞋今猴 编辑:程序博客网 时间:2024/06/11 20:50
这道题目的URL:http://acm.hdu.edu.cn/showproblem.php?pid=2564;
写程序逻辑一定要清晰,有 清晰的逻辑才能写出正确的代码。要找出每个词的首字母,关键在于空格。第一个字母和一个或多个连续字母后的第一个字母便是下个单词的首字母。我用了一个标志位nextIsFirst来标志下一个是否是单词首字母。整个程序围绕这个标识位进行处理。
下面的是我的AC代码,欢迎拍砖。
#include<iostream>#include<string.h>using namespace std;const int Max = 200;char line[Max];char acronym[20];int main(){int cases, pos, len;bool nextIsFirst;cin >> cases;getchar();while(cases--){cin.getline(line, Max);pos = 0;nextIsFirst = true;len = strlen(line);for(int i=0; i<len; i++){if(line[i] == ' '){nextIsFirst = true;}else{if(nextIsFirst){ if(line[i] > 'Z')acronym[pos++] = line[i] - 'a' + 'A';else acronym[pos++] = line[i];nextIsFirst = false;}}}acronym[pos] = '\0';printf("%s\n", acronym); }system("pause");return 0;}
- HDOJ 2564:词组缩写 标志位的用处很大呀
- HDOJ/HDU 2564 词组缩写(单词缩写)
- hdoj 2564 词组缩写 水题,水过~
- hdoj-2564-词组缩写(解题报告)
- 词组缩写 2564
- hdu 2564 词组缩写
- hd 2564词组缩写
- HDU-2564-词组缩写
- 词组缩写 2564HDU
- 2564:词组缩写
- hdu 2564 词组缩写
- HDU 2564 词组缩写
- HDU 2564 词组缩写
- 词组缩写 HDU-2564
- 用处很大的博客
- 杭电2564----词组缩写
- 词组缩写
- 词组缩写
- Android 之 Dialog复选框获取值
- Boa服务器移植
- hadoop 部署、配置、运行
- 怎样才能开发出好的软件
- 基于visual c++之windows核心编程代码分析(22)Mapping File编程
- HDOJ 2564:词组缩写 标志位的用处很大呀
- Silverlight开发历程—动画(线性动画一些效果)
- gzip: stdin: not in gzip format tar: Child returned status 1
- 程序员编程艺术:第十章、如何给10^7个数据量的磁盘文件排序
- 庖丁解牛TLD(四)——Tracking解析
- .net应该要知道的内容
- 基于visual c++之windows核心编程代码分析(23)遍历驱动器并获取驱动器属性
- 大学英语四级,你悲催了没
- 感悟定位人生之一(从前天的项目聚会的失落说起)