首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
苍灵
2025年9月2日 17:22
首字母大写 题解:C++ 关键在于空白符的判定(两种方法)
P1240
回复 0
|
赞 4
|
浏览 168
#include<bits/stdc++.h> using namespace std; int main(){ string s; while(getline(cin,s)){ if(s[0]>=97&&s[0]<=122){ s[0]-=32; } for(int i=1;i<s.length();i++){ // 判断空白符isspace; // 或者这样写也可以:if(s[i-1]==' '||s[i-1]=='\t'||s[i-1]=='\r'||s[...
cczz
2025年8月5日 20:32
首字母大写 题解(采用stl轻松解决):
P1240
回复 0
|
赞 4
|
浏览 221
#include<bits/stdc++.h> using namespace std; int main(){ char s[105]; gets(s); char before = ' '; for(int i = 0; i < strlen(s); i ++){ char ch = s[i]; if(isspace(before) && !isspace(ch)) s[i] = toupper(ch); before = s[i]; cout << before; } ...
古娜拉黑暗之神
2020年4月17日 10:11
布灵布灵
P1240
回复 1
|
赞 34
|
浏览 11.2k
#include<stdio.h> #include<string.h> int main() { char tem[100]; while(gets(tem) != NULL) &nbs...
西电机试专家
2025年3月11日 17:46
首字母大写 题解:非常好理解
P1240
回复 0
|
赞 28
|
浏览 742
#include <bits/stdc++.h> using namespace std; //注意,题目中说输入字符串,那么可能不止含有字母,所以应先判断是否为字母 int main(){ string s; while(getline(cin,s)){ if(s[0]>='a'&&s[0]<<'z') &...
carrot_huan
2025年3月9日 23:34
首字母大写 题解:
P1240
回复 0
|
赞 5
|
浏览 593
#include<iostream> #include<string> using namespace std; int main() { string str; while (getline(cin, str)) { for (int i = 0;i < str.size();i++) &...
jaygee_
2025年3月6日 18:26
首字母大写 题解:
P1240
回复 0
|
赞 1
|
浏览 642
求助!!!PE了,AC60%哪里还需要改进 #include<bits/stdc++.h> using namespace std; int main() { vector<string> words; string s; while(getline(cin, s)) { string word; int n = s.length(); s[0] = toupper(s[0]); for(int i = 0; i < n; i ++) { ...
shiv15832
2025年3月6日 11:48
首字母大写 题解:
P1240
回复 0
|
赞 20
|
浏览 884
其实很简单的题目,定义一个bool flag表示当前位置需不需要转换大写,默认是需要,因为开头字母需要大写,转换之后flag置否,因为转换后不管是后面是什么都不需要大写(空格,标点,字母,数字),这题比较坑爹的一点是数字后面的字母不需要大写,比如4am不要转4Am,单独加一条判断就行了,如果不加会卡60%。 #include<bits/stdc++.h> using namespace std; #define con 'a'-'A' int main(){ char s[105]; &nb...
cHorizon
2025年3月4日 22:43
P1240 首字母大写 答疑提问:
P1240
回复 1
|
赞 8
|
浏览 678
#include <bits/stdc++.h> using namespace std; char s[105]; int main(){ while(gets(s)){ int ls=strlen(s); int flag=0; for(int i...
Chen沧月有泪
2025年2月14日 11:56
首字母大写 题解:
P1240
回复 0
|
赞 13
|
浏览 712
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<string.h> int main() { char s[105]; while (gets(s)) { if (s[0] >= 'a' && s[0] <= 'z') ...
固态氧化碳
2025年2月12日 17:35
首字母大写 题解:注意这题目的要求 不是空格后面首字母要大写 是空白符
P1240
回复 0
|
赞 37
|
浏览 1.2k
卡了我好久 还纳闷怎么回事。。。。 代码如下 func是小写转换成大写 多余的头文件是懒得删了 #include <stdio.h> #include <iostream> #include <string.h> using namespace std; char func(char s) { if(s>='a'&&s<='z') { ...
1
2
3
...
5
题目
首字母大写
题解数量
46
发布题解
在线答疑
热门题解
1
首字母大写 题解:注意这题目的要求 不是空格后面首字母要大写 是空白符!!!
2
布灵布灵
3
首字母大写 题解:
4
首字母大写 题解:非常好理解
5
首字母大写 题解:
6
首字母大写 题解:c++
7
首字母大写 题解:好奇怪,同样的数据,dev运行出来的结果就是对的,怎么复制过来就输出结果只有一个首字母不对唉。附上我得程序代码和截图。
8
首字母大写 题解:
9
首字母大写 题解:
10
P1240 首字母大写 答疑提问: