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. ...
随机推荐
- Sicily 2005.Lovely Number
题目地址:2005.Lovely Number 思路: 若测试数据出现的次数为奇数,则输出它. 所以,可以先排序,若前后相等,前后都设为0,最后不为0的则可以输出. 具体代码如下: #include ...
- uva 371 - Ackermann Functions
#include <cstdio> int main() { long int F, S, I, Count, Value, Max, J; while(scanf("%ld % ...
- Mysql启动失败 MYSQL:The server quit without updating PID file
MySQL5.6启动时出错 提示MYSQL:The server quit without updating PID file 首先执行 /bin/mysqld_safe --user=mysql & ...
- PHP内置Web Server探究(二)自定义PHP控制台输出console函数
我们在开发APP的服务器端,当和APP进行联调时通常需要实时跟踪URL请求和参数的接收情况. 但PHP并没有像Python或Java专有的控制台输出函数,Python的print()和Java的Sys ...
- HTML&CSS基础学习笔记1-简单网页中有哪些标签?
一个简单网页中有哪些HTML标签? 平时我们看到的网页,都是由HTML的标签来组成的.HTML标签非常多,我们先来认识一部分. 1. <html></html>称为根标签,所有 ...
- 怎样使用pyinstaller打包
安装好pyinstaller后 cd 到pyinstaller.py目录,在命令行输入:python pyinstaller.py 参数 主文件所在目录 如:python pyinstaller.py ...
- Java学习笔记--StringTokenizer的使用
拓展:Pattern.split替代String.split http://www.cnblogs.com/gnivor/p/4386978.html StringTokenizer是一个用来分隔St ...
- bzero()等的区别
bzero 原型: extern void bzero(void *s, int n); 用法: #include <string.h> 功能:置字节字符串s的前n个字节为零. 说 ...
- 使用 ExpandableListView 实现折叠ListView
1:layout/expandablelistview_groups.xml 标题文件 <?xml version="1.0" encoding="utf-8&qu ...
- cf C. Dima and Containers
http://codeforces.com/contest/358/problem/C 将最大的放在stack里面,第二大的放在queue中,第三大的放在deck里面.然后模拟就可以了. #inclu ...