现在的位置: 首页 > 综合 > 正文

Another Very Easy Task 我也不知道怎么会过不了?

2013年10月10日 ⁄ 综合 ⁄ 共 674字 ⁄ 字号 评论关闭
View Code
#include <stdio.h>
#include <string.h>
int main()
{
    char s[100000];
    int l,j;
    while ( gets(s)!=NULL )
    {
        int i=0;
        l=strlen(s);
        while (i<l)    
        {
            int j=0;
            int k=i;
            while ( ((s[i]>='A')&&(s[i]<='Z')) || ((s[i]>='a')&&(s[i]<='z')))
                {
                    j++;
                    i++;
                }
            if (j>2) printf("%c%d%c%c",s[k],j-2,s[i-1],s[i]);
            else if (j==2) printf("%c%c%c",s[k],s[k+1],s[k+2]);
            else if (j==1) printf("%c%c",s[k],s[k+1]);
            else if (j==0) printf("%c",s[i]);
            i++;
        }
        printf("\n");
    }
    return 0;
}

抱歉!评论已关闭.