hdu 2564 词组缩写
Problem Description
定义:一个词组中每个单词的首字母的大写组合称为该词组的缩写。
比如,C语言里常用的EOF就是end of file的缩写。
Input
输入的第一行是一个整数T,表示一共有T组测试数据;
接下来有T行,每组测试数据占一行,每行有一个词组,每个词组由一个或多个单词组成;每组的单词个数不超过10个,每个单词有一个或多个大写或小写字母组成;
单词长度不超过10,由一个或多个空格分隔这些单词。
Output
请为每组测试数据输出规定的缩写,每组输出占一行。
Sample Input
1
end of file
Sample Output
EOF
终于AC了!!!!!
代码:
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <stdio.h>
using namespace std;
int main()
{
string st;
char ch[15];
int n,m,i,j,k;
while(scanf("%d",&n)!=EOF)
{ getchar();
while(n--)
{ j=0;
getline(cin,st);
for(i=0;i<st.size();i++)
{
if(st[i]==' '&&((st[i+1]>='A'&&st[i+1]<='Z')||(st[i+1]>='a'&&st[i+1]<='z')))
{
if(st[i+1]>='A'&&st[i+1]<='Z')
ch[j++]=st[i+1];
else
ch[j++]=st[i+1]-32;
}
}
for(i=0;i<st.size();i++)
{
if(st[i]!=' ') break;
}
if(i==0)
{
if(st[0]>='a'&&st[0]<='z')
st[0]=st[0]-32;
cout<<st[0];
}
for(i=0;i<j;i++)
cout<<ch[i];
cout<<endl;
}
}
return 0;
}
hdu 2564 词组缩写的更多相关文章
- HDOJ/HDU 2564 词组缩写(单词缩写)
Problem Description 定义:一个词组中每个单词的首字母的大写组合称为该词组的缩写. 比如,C语言里常用的EOF就是end of file的缩写. Input 输入的第一行是一个整数T ...
- (stringstream toupper 空格) 词组缩写 hdu2564
词组缩写 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submi ...
- 词组缩写(isalpha()的应用)
Problem Description 定义:一个词组中每个单词的首字母的大写组合称为该词组的缩写.比如,C语言里常用的EOF就是end of file的缩写. Input 输入的第一行是一个整数 ...
- HDU2564 词组缩写
2019-06-03 15:00:38 感觉有有种被坑了的感觉,这道题不难,就是一再的W,
- HDU 2564 饭卡
饭卡 Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submissi ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- [转] HDU 题目分类
转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...
- HDU ACM 题目分类
模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
随机推荐
- js大文件分割上传
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xht ...
- Redis VS Memcached 转载
引子: 在大数据时代,总希望存在一个Key-value存储机制,像HashMap一样在内存中处理大量(千万数量级)的key-value对,以便提高数据查找.修改速度. 所以,我们会想到,Memcach ...
- dede分页
{dede:list pagesize ='} <div class="intro clearfix"> <ul class="pic"> ...
- python list内容拷贝方法
先看如下代码: x = ['a','b','z'] y = x print y y[0] = 'w' print x,y 结果输出: >>> ['a', 'b', 'z'] #y l ...
- java并发编程_建立概念
在学习多线程编程时,相信大家会遇到好多概念类的东西,对于这些概念的不准确理解会导致后面越学越糊涂,现将学习过程中遇到的概念整理到这篇博客上,一来记录学习点滴,二来也加深理解,如果有理解不准确的地方,希 ...
- rsyslog的ommsql模块如何连接MYSQL的非标准数据库端口?
搞了我半小个时查找资料..最后,在一个官方文档中找到他... http://www.rsyslog.com/doc/ommysql.html Sample: The following sample ...
- How to install phpmyadmin on centos 6
Phpmyadmin : Phpmyadmin is a free tool used to administrate MySQL . Phpmyadmin supports all major ...
- STL中erase的小心使用
先看如下一道改错题: #include<iostream> #include<vector> using namespace std; void print(vector< ...
- Putty server refused our key的解决方法
在使用putty工具使用密钥远程登陆CentOS系统时,出现Putty server refused our key提示,解决办法: 1.查看是否关掉SELINUX. 相关命令:getenforce, ...
- 集成Dubbo服务(Spring)
Dubbo是什么? Dubbo是阿里巴巴SOA服务化治理方案的核心框架,每天为2,000+个服务提供3,000,000,000+次访问量支持,并被广泛应用于阿里巴巴集团的各成员站点. Dubbo[]是 ...