首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
苍灵
2025年9月2日 18:46
字符串排序 题解:C++
P1254
回复 0
|
赞 0
|
浏览 131
#include<bits/stdc++.h> using namespace std; int main(){ string s; while(cin>>s){ for(int i=0;i<s.length()-1;i++){ for(int j=i;j<s.length();j++){ if(int(s[i])>int(s[j])){ swap(s[i],s[j]); } } } cout<<s<<endl; } return...
cczz
2025年8月6日 17:23
字符串排序 题解:
P1254
回复 0
|
赞 2
|
浏览 201
#include<bits/stdc++.h> using namespace std; int main(){ char a[25]; cin >> a; sort(a, a+strlen(a)); for(int i = 0; i < strlen(a); ) cout << a[i++]; return 0; }
阿灿
2025年3月21日 16:36
字符串排序 题解:
P1254
回复 0
|
赞 3
|
浏览 501
#include<bits/stdc++.h> using namespace std; int main(){ string n; while(cin>>n){ sort(n.begin(),n.end()); cout<<n<<endl; } return 0; }
cc12345
2025年3月17日 16:35
字符串排序 题解:
P1254
回复 0
|
赞 1
|
浏览 466
#include<bits/stdc++.h> using namespace std; bool cmp_up(char a,char b) { return a<b; } int main(){ string s; getline(cin,s); stable_sort(s.begin(),s.end(),cmp_up); //数组可用长度加,而节点,字符串可以使用begin(),end(); for(auto a:s) cout<<a; return 0; }
yeee700
2025年3月12日 23:15
字符串排序 题解:
P1254
回复 0
|
赞 0
|
浏览 554
#include<stdio.h> #include <stdlib.h> #include<string.h> int cmp(const void* a,const void*b){ char pa=*(char*)a; char pb=*(char*)b; return pa-pb; } int main(){ char str[20]; while(gets(str)&&strlen(str)!=0){ int n=strlen(str); qsor...
zxjrheaven
2025年3月12日 18:44
字符串排序 题解:暴力
P1254
回复 0
|
赞 2
|
浏览 749
#include <bits/stdc++.h> using namespace std; char str[21]; bool cmp(char a,char b) { return a<b; } int main() { cin>>str; int a=strlen(str); sort(str,str+a,cmp); cout&l...
shiv15832
2025年3月9日 18:32
字符串排序 题解:sort秒杀
P1254
回复 0
|
赞 5
|
浏览 720
唯一需要注意的点在于:如果要用ls记录字符串的长度,字符串应定义为char s[50]而不是string类型,因为strlen()是c的函数,string是c++类型,二者不兼容。我认为不需要死记硬背,只要有点印象,看见编译报错能改对就可以了。参考别人的题解还有别的解决方案,只要类型一一对应就可以,就不赘述了。 #include<bits/stdc++.h> using namespace std; int main(){ char s[50]; gets(s);//cin也可以 &n...
18919717626
2024年7月6日 21:22
字符串排序 题解:sort(s.begin(),s.end())
P1254
回复 0
|
赞 10
|
浏览 1.1k
#include <iostream> #include <algorithm> using namespace std; int main(){ string s; cin >> s; sort(s.begin(),s.end()); cout << s << endl; return 0; }
Candour
2024年4月29日 00:02
字符串排序 (C++)题解:
P1254
回复 0
|
赞 3
|
浏览 992
#include<bits/stdc++.h> using namespace std; int main() { string str; while(cin >> str) { sort(str.begin(), str.end()); cout << str; } return 0; }
潇风青禾
2024年3月26日 11:43
字符串排序 题解:
P1254
回复 0
|
赞 0
|
浏览 763
#include<bits/stdc++.h> using namespace std; int main(){ char s[20]; gets(s); sort(s, s+strlen(s)); puts(s); return 0; }
1
2
3
题目
字符串排序
题解数量
27
发布题解
在线答疑
热门题解
1
字符串排序 题解:sort(s.begin(),s.end())
2
字符串排序 题解:sort秒杀
3
字符串排序 题解:
4
字符串排序 (C++)题解:
5
字符串排序 题解:
6
字符串排序 题解:
7
字符串排序 题解:sort实现
8
字符串排序 题解:c 送分
9
字符串排序 题解:暴力
10
字符串排序 题解:题目要求多组,许多通过没有这个也过了