zoukankan      html  css  js  c++  java
  • codeforces71A

    Way Too Long Words

     CodeForces - 71A 

    XUPT_ACM的杨队是一个强迫症晚期的大神,他特别反感长单词,就像 "localization" 和"internationalization" 。

    于是睿智的杨队想出了一个方法来节约写单词的时间, 如果单词的长度严格大于10个字符,那么他可以用以下方法表示:

    写下这个单词的第一个字母与最后一个字母,在它们之间写下除去第一个字母和最后一个字母后该单词包含的字母个数,这个数字是不包含前导零的十进制数字。

    举个栗子, "localization" 可以表示为"l10n", "internationalization"可以被表示为"i18n".

    你的任务是通过编写代码实现这样一个转化的过程,太长的单词通过上述方法表示,其他的单词保持不变

    Input

    第一行包含一个整数n (1 ≤ n ≤ 100). 接下来n行每行包含一个单词. 所有的单词由小写字母组成,单词的长度为1 到100个字符.

    Output

    输出 n 行. 第 i 行包括第 i 个单词的转化结果.

    Examples

    Input
    4
    word
    localization
    internationalization
    pneumonoultramicroscopicsilicovolcanoconiosis
    Output
    word
    l10n
    i18n
    p43s

    sol:直接按题意模拟就可以了
    #include <bits/stdc++.h>
    using namespace std;
    typedef int ll;
    inline ll read()
    {
        ll s=0;
        bool f=0;
        char ch=' ';
        while(!isdigit(ch))
        {
            f|=(ch=='-'); ch=getchar();
        }
        while(isdigit(ch))
        {
            s=(s<<3)+(s<<1)+(ch^48); ch=getchar();
        }
        return (f)?(-s):(s);
    }
    #define R(x) x=read()
    inline void write(ll x)
    {
        if(x<0)
        {
            putchar('-'); x=-x;
        }
        if(x<10)
        {
            putchar(x+'0'); return;
        }
        write(x/10);
        putchar((x%10)+'0');
        return;
    }
    #define W(x) write(x),putchar(' ')
    #define Wl(x) write(x),putchar('
    ')
    const int N=105;
    char S[N];
    int main()
    {
        int T;
        R(T);
        while(T--)
        {
            scanf("%s",S+1);
            int Len=strlen(S+1);
            if(Len<=10) printf("%s
    ",S+1);
            else
            {
                putchar(S[1]);
                write(Len-2);
                putchar(S[Len]);
                putchar('
    ');
            }
        }
        return 0;
    }
    View Code
     
  • 相关阅读:
    mybatis中的延迟加载
    MyBatis的mapper
    MyBatis的resultMap
    mybatis入门
    mybatis中的#和$的区别(转)
    操作日志记录
    SpringMVC中的异常处理集锦
    vue.js的package.json相关问题解惑
    git的常用操作指令
    http协议参数详解
  • 原文地址:https://www.cnblogs.com/gaojunonly1/p/10574953.html
Copyright © 2011-2022 走看看