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. Vim配置说明

    使用这些天一直vim,我认为vim这是一个非常强大的编辑器,尤其是后配置. 互联网参考大牛个月vim配置,然后更改加入了一部分,形成了自己的配置.让Vim变的更强大. 详细有下面几个特点: 1.自己主 ...

  2. CSDN 夏令营课程 项目分析

    主题如以下: 正确改动后的程序: #include <iostream.h> //using namespace std; class BASE { char c; public: BAS ...

  3. [LeetCode53]Maximum Subarray

    问题: Find the contiguous subarray within an array (containing at least one number) which has the larg ...

  4. mvc+webapi+dapper+ef codefirst项目搭建

    首先项目是mvc5+webapi2.0+orm数据处理(dapper)+ef动态创建数据库. 1.项目框架层次结构: mvc项目根据不同的业务和功能进行不同的区域划分[今后项目维护起来方便],mode ...

  5. 系列五AnkhSvn

    原文:系列五AnkhSvn AnkhSvn介绍 AnkhSVN是一款在VS中管理Subversion的插件,您可以在VS中轻松的提交.更新.添加文件,而不用在命令行或资源管理器中提交.而且该插件属于开 ...

  6. 一个可以跑的Hadoop的WordCount程序

    搭个新环境时总要折腾一下,于是干脆记下来. 程序: package com.my; import java.io.IOException; import java.util.Iterator; imp ...

  7. 使用shell/python获取hostname/fqdn释疑(转)

    一直以来被Linux的hostname和fqdn(Fully Qualified Domain Name)困惑了好久,今天专门抽时间把它们的使用细节弄清了. 一.设置hostname/fqdn 在Li ...

  8. default argument given of parameter 的问题

    今天写了一个类,当中的一个方法用到了默认參数,结果报了  "default argument given of parameter 的问题 " 错误. 类头文件的声明例如以下: v ...

  9. 解决因特网和xshell考虑到问题

    首先需要解释.我们学校的网络是免费的.无论是实验室或宿舍.因此,互联网是基于Mac地址分配IP的,所以我VirtualBox安装了centos之后,话.就须要将VirtualBox的mac地址改成和我 ...

  10. SQL Server 2008 R2 性能计数器详细列表(二)

    原文:SQL Server 2008 R2 性能计数器详细列表(二) SQL Server Buffer Partition 对象: 提供计数器来监视 SQL Server 如何使用可用页 SQL S ...