简单模拟题。

CODE:

#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#include "math.h"
#include "ctype.h"
using namespace std;

char a[101], str[101];

int main()
{
    int i, j;
    int t;
    scanf("%d", &t);
    getchar();
    while (t--)
    {
        gets(a);
        
        int len = strlen(a);
        i = 0; j = 0;
        while(a[i] == 32) i++;
        if(islower(a[i])) str[j++] = a[i] - 32;
        else str[j++] = a[i];
        i++;
         while (i < len-1)
        {
            if(a[i] == 32 && a[i+1] != 32
            {
                if(islower(a[i+1])) str[j++] = a[i+1]-32;
                else    str[j++] = a[i+1];
            }
            i++;
        }
        str[j]='\0';
        puts(str);
    }
    return 0;

} 

posted on 2012-07-21 21:13  有间博客  阅读(281)  评论(0)    收藏  举报