首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
Yw1111111
2024年3月6日 14:41
首字母大写 题解:Python
P1240
回复 0
|
赞 0
|
浏览 975
set = [' ','\n','\t','\r'] while True: try: all = input() result = "" for i in range(len(all)): if (all[i].isalpha() and all[i-1] in set) or i == 0: result += all[i].upper() els...
zhangan
2024年3月6日 11:35
首字母大写 题解:
P1240
回复 1
|
赞 2
|
浏览 1.5k
//只有80%的正确率,有大佬帮忙看看吗 #include <stdio.h> #include <ctype.h> #include <string.h> void capitalize_words(char *str) { int i = 0; // 处理第一个字符 if (islower(str[0])) { str[0] = toupper(str[0]); &nbs...
williams
2024年3月6日 11:21
首字母大写 题解:
P1240
回复 0
|
赞 1
|
浏览 1.2k
别忘考虑已经大写了的情况 #include <stdio.h> #include <stdbool.h> #include <math.h> #include <string.h> int main(void) { char s[100]; while(gets(s)!=NULL){ for(int i=0;i<strlen(s);i++){ if(i==0&&(s[i]>='a'&&s[i]<='z'))...
halo_777
2024年2月18日 20:16
首字母大写 题解:
P1240
回复 0
|
赞 0
|
浏览 1.6k
#include<bits/stdc++.h> using namespace std; char s[100]; int main() { while (gets(s)) { int len = strlen(s); if (s[0] <= 'z' && s[0] >= 'a') s[0] = s[0] - 'a' + 'A'; for (int i = 1; i < len; i++) { if (s[i-1] == ' '...
小王桐学
2024年1月27日 14:04
首字母大写 题解:
P1240
回复 0
|
赞 1
|
浏览 1.3k
#include <stdio.h> #include <stdlib.h> #include <string.h> void Initial_B(char *s) { int i = 0,j; while(s[i] != '\0') { j = i; // while((s[j] >= 'a' && s[j] <= 'z') || (s[j] >= 'A' && s[j] <= 'Z')) while(s[j] != ' ' &a...
Cookie‘s AE86
2024年1月17日 10:53
首字母大写 题解:C++
P1240
回复 0
|
赞 1
|
浏览 1.5k
#include<bits/stdc++.h> using namespace std; int main(){ char s[100]; int judge ; while( gets(s)){ judge = 1; int len = strlen(s) ; for(int i = 0 ;i < len ;i++){ if(judge == 1 && s[i] <= 'z' && s[i] >= '...
dcsy
2023年10月3日 19:26
首字母大写 题解:
P1240
回复 2
|
赞 0
|
浏览 1.7k
60%通过率。看的脑袋发昏,帮帮孩子吧,好心人 #include<stdio.h> int main(){ char str[100]; fgets(str, sizeof(str), stdin); int i = 0,k = 0; for(; str[i] != '\0'; i++){ if(str[i] == ' '){ k = 0; }else if(str[i] >= 'a' && str[i] <= 'z'){ if(k == 0){ k = ...
Syou
2023年8月14日 16:12
首字母大写 题解:
P1240
回复 2
|
赞 1
|
浏览 1.6k
C++ 求帮助!通过率只有80% 实在想不到有什么问题了,在本地试了很多测试用例 #include <iostream> #include <string> using namespace std; int main(){ string str; while(getline(cin, str)){ string::iterator sit; bool flag = true; for(sit = str.begin(); sit != str.end(); sit++){ if(*sit == ' ' ...
dongqing
2023年7月27日 18:19
首字母大写 题解:
P1240
回复 0
|
赞 0
|
浏览 1.5k
注意制表符'\t' 也需要大写 #include<bits/stdc++.h> using namespace std; int main(){ string s; while(getline(cin,s)) { if(s[0]>='a'&&s[0]<='z') { s[0]=s[0]+'A'-'a'; } for(int i=1;i<s.size();i++) ...
jix::c
2023年5月5日 23:10
首字母大写 题解:
P1240
回复 0
|
赞 1
|
浏览 2.1k
注意事项: 1. 可能是大写字母,要判断是小写之后在处理(如果使用toupper就不用判断) 2. 模拟判断前一位首先处理s[0] 3. 使用库函数isalpha和islower和toupper简化代码 AC代码 #include <bits/stdc++.h> #define fi first #define endl '\n' #define se second #define pp pop_back #define pb push_back #define lowbit(x) ((x)&(-(x))) #d...
1
...
3
4
5
6
题目
首字母大写
题解数量
60
发布题解
在线答疑
热门题解
1
首字母大写 题解:注意这题目的要求 不是空格后面首字母要大写 是空白符!!!
2
首字母大写 题解:非常好理解
3
布灵布灵
4
首字母大写 题解:C++ 关键在于空白符的判定(两种方法)
5
首字母大写 题解:
6
应对多种情况:单词首字母已经大写、1st这种数字开头的单词等
7
首字母大写 题解:
8
首字母大写 题解:c++
9
首字母大写 题解:
10
首字母大写 题解:好奇怪,同样的数据,dev运行出来的结果就是对的,怎么复制过来就输出结果只有一个首字母不对唉。附上我得程序代码和截图。