[Upper case conversion ] 每个单词的首小写字母转换为对应的大写字母

时间:2023-03-09 03:37:29
[Upper case conversion ] 每个单词的首小写字母转换为对应的大写字母

Given a string , write a program to title case every first letter of words in string.

Input:
The first line consists of an integer T i.e number of test cases. The first and only line of each test case consists of a string s.

Output:
Print the required output.

Constraints: 
1<=T<=100
1<=|Length of string|<=1000

Example:
Input:
1
I love programming

Output:
I Love Programming

下面是我的代码实现:

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main()
{
    int num;//num组用例
    scanf("%d\n",&num);
    int i,j;
    ;j<num;j++)
    {
        );
        gets(a);
        ])&&]&&a[]<='z')//判断第一个字母是否是小写
        {
            a[]=a[]-;
        }
        ;i<=strlen(a);i++)
        {
            ])&&'a'<=a[i]&&a[i]<='z')//前一个是空格,后一个是小写字母。
            {
                a[i]=a[i]-;
            }
        }
        puts(a);
    }
    ;
}

如有问题,请留言