LeeBlog

导航

HDU 2564 词组缩写

这个要注意把缩写的最后一个字符串置为0

#include<stdio.h>
#include<string.h>
#include<ctype.h>
char str[1000],s[1000];
int main( )
{
    int t;
    scanf( "%d%*c",&t );
    while( t-- )
    {
           gets( str );
           int i = 0,c = 0;
           while( str[i] )
           {
                  if( !isalpha( str[i] ) )
                  {
                      ++i;
                      continue;
                  }
                  if( str[i] > 'Z' )
                      str[i] -= 32;
                  s[c++] = str[i];
                  while( isalpha( str[i] ) )
                         ++i;
                  }
           s[c] = 0;
           puts( s );
           }
    return 0;
}

posted on 2011-05-11 17:40  LeeBlog  阅读(313)  评论(0编辑  收藏  举报