Problem Description
定义:一个词组中每个单词的首字母的大写组合称为该词组的缩写。
比如,C语言里常用的EOF就是end of file的缩写。
 
Input
输入的第一行是一个整数T,表示一共有T组测试数据;
接下来有T行,每组测试数据占一行,每行有一个词组,每个词组由一个或多个单词组成;每组的单词个数不超过10个,每个单词有一个或多个大写或小写字母组成;
单词长度不超过10,由一个或多个空格分隔这些单词。
 
Output
请为每组测试数据输出规定的缩写,每组输出占一行。
 
Sample Input
1
end of file
 
Sample Output
EOF
本题要考虑的情况:
   asd   asd
asd asd   asd
 
 
 #include <stdio.h>
#include <math.h>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <string>
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std;
char str[],s[];
int main( )
{
int t;
scanf( "%d%*c",&t );
while( t-- )
{
gets( str );
int i = ,c = ;
while( str[i] )
{
if( !isalpha( str[i] ) )//如果输入字符是一个英文字母,即 a-z或A-Z,返回非零值(具体返回多少要看系统实现),否则返回0.
{
++i;
continue;
}
if( str[i] > 'Z' )
str[i] -= ;
s[c++] = str[i];
while( isalpha( str[i] ) )
++i;
}
s[c] = ;
puts( s );
}
return ;
}
分解:
 #include<stdio.h>
#include<stdlib.h>
#include<string.h>
char a[],b[];
int main()
{
int T;
int i;
int len=;
int k;
scanf("%d",&T);
getchar();
while(T--)
{
gets(a);
len=strlen(a);
strupr(a);
k=;
for(i=;i<len;i++)
{
if(i==)
{
if(a[i]==' ' && a[i+]!=' ')
b[k++]=a[i+];
else if(a[i]!=' ')
b[k++]=a[i];
}
else
{
if(a[i]==' ' && a[i+])
b[k++]=a[i+];
}
}
for(i=;i<k;i++)
{
if(b[i]!=' ')
printf("%c",b[i]);
}
printf("\n");
}
return ;
}
 

词组缩写(isalpha()的应用)的更多相关文章

  1. (stringstream toupper 空格) 词组缩写 hdu2564

    词组缩写 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  2. HDOJ/HDU 2564 词组缩写(单词缩写)

    Problem Description 定义:一个词组中每个单词的首字母的大写组合称为该词组的缩写. 比如,C语言里常用的EOF就是end of file的缩写. Input 输入的第一行是一个整数T ...

  3. hdu 2564 词组缩写

    Problem Description 定义:一个词组中每个单词的首字母的大写组合称为该词组的缩写. 比如,C语言里常用的EOF就是end of file的缩写. Input 输入的第一行是一个整数T ...

  4. HDU2564 词组缩写

    2019-06-03 15:00:38 感觉有有种被坑了的感觉,这道题不难,就是一再的W,

  5. [LeetCode] Minimum Unique Word Abbreviation 最短的独一无二的单词缩写

    A string such as "word" contains the following abbreviations: ["word", "1or ...

  6. [LeetCode] Valid Word Abbreviation 验证单词缩写

    Given a non-empty string s and an abbreviation abbr, return whether the string matches with the give ...

  7. [LeetCode] Unique Word Abbreviation 独特的单词缩写

    An abbreviation of a word follows the form <first letter><number><last letter>. Be ...

  8. 常用CSS缩写语法总结

    使用缩写可以帮助减少你CSS文件的大小,更加容易阅读.css缩写的主要规则如下: 颜色 16进制的色彩值,如果每两位的值相同,可以缩写一半,例如:#000000可以缩写为#000;#336699可以缩 ...

  9. Mac Mail PGP Setup 如何在苹果电脑上设置安全邮件 良好隐私密码法(英语:Pretty Good Privacy,缩写为PGP)

    背景知识 良好隐私密码法(英语:Pretty Good Privacy,缩写为PGP),一套用于讯息加密.验证的应用程序,采用IDEA的散列算法作为加密与验证之用. 关联文献:https://en.w ...

随机推荐

  1. Lua 服务器与客户端实例(转)

    =============================================================== 服务器,main.lua ======================= ...

  2. Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.ClassVisitor

    1.错误描写叙述 信息: Setting autowire strategy to name 2014-7-13 1:37:43 org.apache.struts2.spring.StrutsSpr ...

  3. hdu 3333 树状数组+离线处理

    http://acm.hdu.edu.cn/showproblem.php?pid=3333 不错的题,想了非常久不知道怎么处理,并且答案没看懂,然后找个样例模拟下别人的代码立即懂了---以后看不懂的 ...

  4. [LeetCode283]Move Zeros将一个数组中为0的元素移至数组末尾

    题目: Given an array nums, write a function to move all 0's to the end of it while maintaining the rel ...

  5. Linux/UNIX数据文件和信息系统

    数据文件和信息系统 密码文件 在存储/etc/passwd在.以下功能可以用来获得密码文件条目. #include <sys/types.h> #include <pwd.h> ...

  6. VirtualBox创建虚拟电脑、执行Genymotion模拟器报错

    当安装完Genynition关于Android应用的调试模拟器之后,在Genymotion执行的平台virtualBox:VirtualBox创建虚拟电脑.执行Genymotion模拟器报错: 错误卖 ...

  7. web压力测试-pylot

    我已经写在使用前Web Bench做压力測试.http://blog.csdn.net/jacson_bai/article/details/41143713 但这个測试,測试结果非常好.缺点就是,无 ...

  8. 在SSMS里查看TDS数据包内容

    原文:在SSMS里查看TDS数据包内容 在SSMS里查看TDS数据包内容 摘抄自<SQLSERVER2012实施与管理实战指南> 要具体查看TDS数据库的内容,我们可以: 用NETWORK ...

  9. java中float/double浮点数的计算失精度问题(转)

    如果我们编译运行下面这个程序会看到什么? public class Test  {    public static void main(String args[]) {                ...

  10. SQL Server高可用——日志传送(4-3)——使用

    原文:SQL Server高可用--日志传送(4-3)--使用 顺接上一篇:SQL Server高可用--日志传送(4-2)--部署 本文为本系列最重要的一篇,讲述如何使用日志传送及一些注意事项.从上 ...