首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
苍灵
2025年9月2日 18:36
删除字符串2 题解:C++
P1027
回复 0
|
赞 3
|
浏览 184
#include<bits/stdc++.h> using namespace std; string sShan(string s){ string s1; int l=0; while(l<s.length()){ if((s[l]=='G'||s[l]=='g')&&(s[l+1]=='Z'||s[l+1]=='z')&&(s[l+2]=='U'||s[l+2]=='u')){ l+=3; }else{ s1+=s[l]; l++; } } return s1...
cczz
2025年8月5日 21:21
删除字符串(正则表达式解法,两行核心代码):
P1027
回复 0
|
赞 3
|
浏览 189
1.正则表达式解法 #include <bits/stdc++.h> using namespace std; int main() { string s; getline(cin, s); // 使用 icase 标志实现大小写不敏感 regex pattern("gzu", regex_constants::icase); string result = regex_replace(s, pattern, ""); cout << result; ret...
cc12345
2025年3月17日 10:41
删除字符串2 题解:后值覆盖gzu,判断数目再输出。
P1027
回复 1
|
赞 17
|
浏览 1.0k
#include<bits/stdc++.h> using namespace std; int main(){ string s; getline(cin,s); int len=s.length(); int num=0; for(int i=0;i<len-3;i++) { if((s[i]=='G'||s[i]=='g')&&(s[i+1]=='Z'||s[i+1]=='z')&&(s[i+2]=='U'||s[i+2]=='u')) { num+=3; for(int j=i;j<len-...
leo110
2025年5月8日 13:31
删除字符串2 题解:思路:先转换成小写,找到位置后把原字符串的对应位置
P1027
回复 0
|
赞 0
|
浏览 423
#include<iostream> #include<string> #include<vector> #include<sstream> using namespace std; //思路:先转换成小写,找到位置后把原字符串的对应位置置为空格,再模仿cin输入流,将多个字符串拼接 int main(){ string str,s,mode="gzu"; cin>>str;  ...
16696033405
2025年3月24日 17:42
删除字符串2 题解:
P1027
回复 0
|
赞 6
|
浏览 548
#include <stdio.h> #include <string.h> #include <ctype.h> #define MAX 1000 int main() { char s[MAX], result[MAX]; int i = 0, j = 0; // 读取输入 fgets(s, MAX, stdin); s[strcspn(s, "\n")] = ...
123456上岸
2025年3月17日 20:16
删除字符串2 题解:
P1027
回复 0
|
赞 11
|
浏览 717
#include<iostream> #include<string> using namespace std; int main(){ string s; cin>>s; int flag = 1; while(flag){ int t=-1; //记录出现“gzu”下标 ...
ASDF807
2025年3月15日 15:47
删除字符串2 题解:C
P1027
回复 0
|
赞 13
|
浏览 675
#include<stdio.h> #include<string.h> int main() { char str[100]; fgets(str,101,stdin); int len = strlen(str)-1; for(int i=0;i<len;i++) { if((str[...
阿灿
2025年3月15日 06:09
删除字符串2 题解:直接八种情况上
P1027
回复 0
|
赞 4
|
浏览 537
#include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; while(s.find("gzu")!= string::npos){ s.erase(s.find("gzu"),3); } while(s.find("Gzu")!= string::npos){ s.erase(s.find("Gzu"),3); } while(s.find("GZU")!= string::npos){ s.erase(s.find("...
blackbook537
2025年3月13日 11:14
删除字符串2 题解:memmove加strncasecmp
P1027
回复 0
|
赞 1
|
浏览 599
#include<stdio.h> #include<string.h> #include<ctype.h> char *strcasestr(const char *haystack, const char *needle){ if(!*needle) return (char *)haystack; size_t needle_len = strlen(needle); for(; ...
cccccuda
2025年3月12日 21:27
删除字符串2 题解:复制一份转小写
P1027
回复 0
|
赞 5
|
浏览 546
#include <iostream> using namespace std; int main() { string s; getline(cin,s); string cpy=s; //将s全部转化为小写 for(int i=0; i<s.size(); i++) { if(s[i]>='A'&...
1
2
3
...
6
题目
删除字符串2
题解数量
51
发布题解
在线答疑
热门题解
1
删除字符串2 题解:C
2
简单易懂
3
删除字符串2 题解:后值覆盖gzu,判断数目再输出。
4
删除字符串2 题解:
5
删除字符串2 题解:
6
删除字符串2 题解:C
7
删除字符串2 题解:
8
删除字符串2 题解:C++
9
删除字符串2 题解:
10
删除字符串2 题解: