HDU 2564 词组缩写

词组缩写

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7539    Accepted Submission(s): 2416


Problem Description
定义:一个词组中每个单词的首字母的大写组合称为该词组的缩写。
比如,C语言里常用的EOF就是end of file的缩写。
 
Input
输入的第一行是一个整数T,表示一共有T组测试数据;
接下来有T行,每组测试数据占一行,每行有一个词组,每个词组由一个或多个单词组成;每组的单词个数不超过10个,每个单词有一个或多个大写或小写字母组成;
单词长度不超过10,由一个或多个空格分隔这些单词。
 
Output
请为每组测试数据输出规定的缩写,每组输出占一行。
 
Sample Input
1 end of file
 
Sample Output
EOF
 
Author
lemon
 
Source
 
Recommend
yifenfei
 
思路:恶心题
 
代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
char map[101000];
int len;
int t;
int main()
{
scanf("%d",&t);
getchar();
while(t --)
{
memset(map,0,sizeof(map));
gets(map);
len = strlen(map);
if(map[0] != ' '){
if(map[0] > 96)
printf("%c",map[0] - 32);
else
printf("%c",map[0]);}
for(int i = 0;i < len;i ++)
if(map[i] == ' ' && i + 1 < len && map[i + 1] != ' '){
if(map[i + 1] > 96)
printf("%c",map[i + 1] - 32);
else
printf("%c",map[i + 1]);}
printf(" ");
}
return 0;
}

原文地址:https://www.cnblogs.com/GODLIKEING/p/3330401.html