首页
DreamJudge
院校信息
专业题库
模拟考试
机试真题
上岸课程
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
红毛舒肤佳
2024年3月10日 22:03
字符串排序2 题解:c++借鉴某位题解,并加入了自己理解注释
P1255
回复 1
|
赞 10
|
浏览 1.5k
#include <bits/stdc++.h> using namespace std; bool cmp(char a,char b){ if(a>='a'&&a<='z'&&b>='a'&&b<='z') return a<b; else if(a>='A'&&a<='Z'&&b>='A'&&b<='Z') return a<b; else i...
williams
2024年3月8日 14:39
字符串排序2 题解:为什么用gets就会报错呢 用fgets就没问题
P1255
回复 4
|
赞 2
|
浏览 849
#include <stdio.h> #include <stdbool.h> #include <math.h> #include <string.h> #include <ctype.h> int main(void){ char string[10000],temp,s[10000]; int j,t=0,count=0; while(fgets(string,sizeof(string), stdin)){ for(int i=0;i<strlen(...
Yw1111111
2024年3月8日 14:35
字符串排序2 题解:Python
P1255
回复 0
|
赞 0
|
浏览 612
1255 AC: while True: try: sentence = input() letters = "" for char in sentence: if char.isalpha(): ...
Cookie‘s AE86
2024年1月28日 11:06
字符串排序2 题解:用两个数组分别记录字母,和非字母的下标,将字母排序
P1255
回复 0
|
赞 5
|
浏览 1.0k
#include<bits/stdc++.h> using namespace std ; /* 规则2的要求在算法上表现是排序具有稳定性 */ int tfo(char a) ; bool cmp(char a ,char b); int main(){ char s [200] ; char result [200] ; gets(s); //输入有空格不能使用cin或者scanf int slen = strlen(s) ; char wd [sle...
dongqing
2023年7月31日 10:20
字符串排序2 题解:
P1255
回复 0
|
赞 2
|
浏览 979
借鉴大佬的题解 除了原来的数组外定义了一个新数组存放比较后的字母,定义一个标识符存放该位置是不是符号。 最后输出的时候进行判断如果该位置的标识符为1 则输出源字符串的东西,如果不是则输出新字符串的东西。 自定义cmp 列举几种可能性 排序采用稳定排序 #include<bits/stdc++.h> using namespace std; char s1[10005]; int flag[10005]={0}; bool cmp(char a,char b) { if((a>='a'&&a<='...
老猫
2021年1月13日 10:28
简洁
P1255
回复 1
|
赞 10
|
浏览 11.6k
先将字母提取出来,然后对字母进行排序,在将排序后的字符串写回原字符串 #include <iostream> #include <string> #include <string.h> #include<algorithm> using namespace std; struct zifu { char zi; int id; }str[500]; bool compare(zifu a,zifu b) { if(tolower(a.zi)==tolower(b.zi)) return a.id...
Sacan
2022年6月5日 23:04
每个规则制定一种策略
P1255
回复 0
|
赞 9
|
浏览 6.7k
规则1策略: 在排序比较时,临时将字符统一转成小写在比较,就可以不区分大小写排序。 规则2策略: stable_sort() 规则3策略: 分开处理。将字母按上述策略排序。对于非字母字符,写一个结构体记录每个字符的值和下标并存起来。将字母单独排序完后,再将每一个非字母字符按照下标插入到排序好的字母序列中。 #include <iostream> #include <vector> #include <algorithm> using namespace std; struct teshu{ ...
N诺子言
2021年3月10日 16:19
map记录一下字符
P1255
回复 0
|
赞 0
|
浏览 8.0k
#include<bits/stdc++.h> #define MAXINT 32767 using namespace std; typedef long long ll; bool isLetter(char a) { if((a>='a'&&a<='z')||(a>='A'&&a<='Z')) return true; return false; } int main() { string s; map<int,string> m; whi...
James
2021年1月24日 16:02
使用stable_sort稳定排序
P1255
回复 0
|
赞 6
|
浏览 9.3k
#include <bits/stdc++.h> using namespace std; char s[10005]; char s1[10005]; int flag[10005];//标记非字符元素位置 bool cmp(char a,char b){ if((a>='a'&&a<='z')&&(b>='a'&&b<='z')){ &n...
ccxx123
2021年1月10日 21:43
利用结构数组求解
P1255
回复 1
|
赞 3
|
浏览 9.3k
#include<stdio.h> typedef struct Node { char k; int flag ; }Node; int main() { char s[1000]; struct Node d[1000]; for (int c = 0; c < 1000; c++) {  ...
1
2
3
题目
字符串排序2
题解数量
21
发布题解
在线答疑
热门题解
1
字符串排序2 题解:stablesort,大小写同时排序
2
参考大家的简化了cmp
3
字符串排序2 题解:借鉴了前人的做法
4
简洁
5
字符串排序2 题解:c++借鉴某位题解,并加入了自己理解注释
6
每个规则制定一种策略
7
在前人的基础上又优化了一下,应该是最简易懂了
8
字符串排序2 题解:好题
9
使用stable_sort稳定排序
10
字符串排序2 题解: