zoukankan      html  css  js  c++  java
  • 词组缩写

    Problem Description
    定义:一个词组中每个单词的首字母的大写组合称为该词组的缩写。
    比如,C语言里常用的EOF就是end of file的缩写。
     
    Input
    输入的第一行是一个整数T,表示一共有T组测试数据;
    接下来有T行,每组测试数据占一行,每行有一个词组,每个词组由一个或多个单词组成;每组的单词个数不超过10个,每个单词有一个或多个大写或小写字母组成;
    单词长度不超过10,由一个或多个空格分隔这些单词。
     
    Output
    请为每组测试数据输出规定的缩写,每组输出占一行。
     
    Sample Input
    1
    end of file
     
    Sample Output
    EOF
     
     1 #include <stdio.h>
     2 #include <ctype.h>
     3 
     4 int main(){
     5     int T;
     6     char c;
     7     int first_alpha;
     8     
     9     scanf("%d",&T);
    10     getchar();
    11     
    12     while(T--){
    13         first_alpha=0;
    14         while((c=getchar())!='
    '){
    15             if(isalpha(c)!=0 && first_alpha==0){
    16                 if(islower(c)!=0)
    17                     printf("%c",toupper(c));
    18                     
    19                 else
    20                     printf("%c",c);
    21                     
    22                 first_alpha=1;
    23             }
    24             
    25             if(c==' ')
    26                 first_alpha=0;
    27         }
    28         
    29         printf("
    ");
    30             
    31             
    32     }
    33     
    34     
    35             
    36     return 0;
    37 }
  • 相关阅读:
    数组分割成多个数组
    node-inspector调试工具
    6.17周六随写
    JavaScript设计模式
    JavaScript设计模式
    async源码学习
    Linux信号列表
    php常用Stream函数集介绍
    php进程控制
    php 单例模式与常驻服务
  • 原文地址:https://www.cnblogs.com/zqxLonely/p/4055489.html
Copyright © 2011-2022 走看看