ZSTUOJ刷题11:Problem D.--零起点学算法106——首字母变大写

2023-03-10,,

Problem D: 零起点算法106——首字母变大写

Time Limit: 1 Sec  Memory Limit: 64 MB
Submit: 18252  Solved: 5211

Description

输入一个英文句子,将每个单词的第一个字母改成大写字母。

Input

输入数据包含多个测试实例,每个测试实例是一个长度不超过100的英文句子,占一行。

Output

请输出按照要求改写后的英文句子。

Sample Input

i like acm
i want to get an accepted

Sample Output

I Like Acm
I Want To Get An Accepted
代码如下:
#include<bits/stdc++.h>
using namespace std; int main(){
char a[101];
while(gets(a)!=NULL){
a[0]=toupper(a[0]);
for(int i=1;i<(int)strlen(a);i++){
if(a[i]==' ') a[i+1]=toupper(a[i+1]);
}
printf("%s\n",a);
} return 0;
}

ZSTUOJ刷题11:Problem D.--零起点学算法106——首字母变大写的相关教程结束。

《ZSTUOJ刷题11:Problem D.--零起点学算法106——首字母变大写.doc》

下载本文的Word格式文档,以方便收藏与打印。