首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
苍灵
2025年9月2日 19:20
字符串排序3 题解:C++ cin.ignore()关键
P1261
回复 0
|
赞 0
|
浏览 102
#include<bits/stdc++.h> using namespace std; bool cStr(string s1,string s2){ if(s1.length()>s2.length()){ return true; }else{ return false; } } int main(){ int n; while(cin>>n){ cin.ignore(); string ss[120]; int m=0; for(int i=0;i<n;i++){ ...
cczz
2025年8月6日 17:58
字符串排序3 题解:
P1261
回复 0
|
赞 1
|
浏览 181
#include<bits/stdc++.h> using namespace std; int main(){ int n; while(cin >> n){ getchar(); // 消除回车影响 vector<string> v; while(n --){ string s; getline(cin, s); if(s != "stop") v.push_back(s); else break; } sort(v.begin(), v.end(), ...
leo110
2025年6月4日 21:08
字符串排序3 题解:求长度真就是length啊?这不对吧?
P1261
回复 0
|
赞 0
|
浏览 272
#include<iostream> #include<vector> #include<algorithm> #include<sstream> using namespace std; struct STR{ string s; int length; }; bool compare(struct STR s1,struct STR s2){ return s1.length<s2.leng...
山崎友希
2025年3月17日 17:34
字符串排序3 题解:
P1261
回复 0
|
赞 7
|
浏览 627
#include<stdio.h> #include<string.h> int main(){ int n; while( ( scanf("%d",&n) )!=EOF ){//实现多组输入输出 char s1[100][100]; int i=0; char t; char temp[100...
zxjrheaven
2025年3月14日 20:04
字符串排序3 题解:暴力结构体(无容器)
P1261
回复 0
|
赞 5
|
浏览 826
#include <bits/stdc++.h> using namespace std; struct node { string str; int cd; }jilu[10005]; bool cmp(node a,node b) { return a.cd<b.cd; } int main() { int n; while(cin>...
Elysiaaaaaaa
2025年3月14日 13:48
字符串排序3 题解:
P1261
回复 0
|
赞 6
|
浏览 548
#include<bits/stdc++.h> using namespace std; int main() { int n; 思想:把字符串的长度作为map的key,自动排序 while (cin >> n) { cin.ignore(10000, '...
yeee700
2025年3月13日 13:32
字符串排序3 题解:
P1261
回复 0
|
赞 2
|
浏览 567
在CodeBlocks上能正常运行,为啥在OJ上老是显示Presentation Error(格式错误),有大佬指点吗 #include<stdio.h> #include<string.h> #include<stdlib.h> int cmp(const void *a,const void*b){ char *pa=(char *)a; char *pb=(char*)b; return strlen(pa)-strlen(pb); } int main(){ int n; ...
奥里给
2025年3月12日 19:33
字符串排序3 题解:
P1261
回复 0
|
赞 4
|
浏览 562
#include<iostream> #include<string> #include<algorithm> using namespace std; // 定义结构体,存储字符串的长度和索引 typedef struct node { int len; // 字符串的长度 int index; // 字符串在数组中的索引 } node; string s[1000]; // 存储输入的字符串 int t; &n...
GENARDING
2025年3月10日 12:49
字符串排序3 题解:使用vector +sort(),此方法适用于多种
P1261
回复 0
|
赞 19
|
浏览 737
使用vector +sort(),此方法适用于多种场景,对此不熟悉的可记为这类相关问题的通解 #include <bits/stdc++.h> using namespace std; // 自定义比较函数 bool cmp(const string &a,const string &b){ if(a.length()==b.length()){ return a<b; } return a.length()<b.length(); } int main() { int n; vec...
GENARDING
2025年3月10日 12:37
字符串排序3 题解:
P1261
回复 0
|
赞 3
|
浏览 503
使用vector +sort(),此方法适用于多种场景,对此不熟悉的可记为这类相关问题的通解 #include <bits/stdc++.h> using namespace std; // 自定义比较函数 bool cmp(const string &a,const string &b){ if(a.length()==b.length()){ return a<b; } return a.length()<b.length(); } int main() { int n; vec...
1
2
3
题目
字符串排序3
题解数量
26
发布题解
在线答疑
热门题解
1
注意使用getchar写cmp函数 size() 比较大小就可以了
2
字符串排序3 题解:使用vector +sort(),此方法适用于多种场景
3
字符串排序3 题解:getchar compare自定义
4
字符串排序3(C++) 题解:
5
字符串排序3 题解:
6
字符串排序3 题解 使用getline前需要用getchar()吸收换行符
7
getline与cin一起使用的问题
8
字符串排序3 题解:
9
字符串排序3 题解:暴力结构体(无容器)
10
字符串排序3 题解: