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. 制作service服务,shell脚本小例子(来自网络)

    事先准备工作:源码安装apache .安装目录为/usr/local/httpd 任务需求:1.可通过 service httpd start|stop|status|restart 命令对服务进行控 ...

  2. Python 显示LinkedIn用户作业

    CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-8-18 @author: guaguastd @name: j ...

  3. 简单的虚拟摇杆控制移动(NGUI)

    一.用NGUI创建虚拟摇杆贴图 先创建一个sprite作为背景叫做JoyStick 并添加一个BoxCollider,再创建一个sprite child作为虚拟摇杆中间的按钮,叫做button 二.通 ...

  4. android得知----overridePendingTransition

    1 Activity动画是指从一个切换activity跳到另一个activity随着电影. 它由两部分组成:第一部分是一个activity动画出口:中的第二个另一部分activity动画被访问: 于A ...

  5. uav 11258 String Partition (DP)

    Problem F - String Partition                                                                         ...

  6. 《TCP/IP作品详细解释2:达到》注意事项--IP地址

    1.接口和地址 如下面的图全部本文中讨论的接口和地址的结构看一个示例配置: 上图中显示了我们三个接口样例:以太网接口,SLIP接口和环回接口. 它们都有一个链路层地址作为地址列表中的第一个结点. 显示 ...

  7. 十二周项目三(4)——出口fibnacci第一序列20的数量

    /* * Copyright (c) 2014, 烟台大学计算机学院 * All rights reserved. * 文件名:test.cpp * 作者:陈丹妮 * 完毕日期:2014年 11 月 ...

  8. Java 新特性(4) - JDK 8 新特性

    http://www.360doc.com/content/14/0620/11/1370831_388286071.shtml

  9. MongoDB(两)mongoDB基本介绍

    MongoDB介绍 MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库其中功能最丰富,最像关系数据库的.他支持的数据结构很的松散,是类似json的bjson格式,因此能够存储比 ...

  10. SharePoint 2013 配置启用搜索服务

    原文:SharePoint 2013 配置启用搜索服务 1.安装完毕SharePoint 2013,新建网站集,点击搜索,出现如下错误(因为没配置,别激动). 2.尝试启动服务器场中的服务之Share ...