首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
无名吟
2026年3月14日 11:30
日志排序 C语言题解:qsort排序
P1227
回复 0
|
赞 12
|
浏览 201
坑:毫秒和运行时间不能用字符串比较,要转int和double比较 比如 '40' > '350' ,但实际40<350,因为40前没有补0,因此要转double比较,否则只有75%。 #include<stdio.h> #include<string.h> #include<stdlib.h> typedef struct Log{ char all[100]; char name[15]; char date[15]; int s,f,m,ms; double ...
mlx
2026年3月7日 16:25
日志排序 题解:
P1227
回复 0
|
赞 21
|
浏览 269
#include<iostream> #include<sstream> #include<algorithm> using namespace std; const int N=10010; struct lg{ string s; string name; string date; string time; double cost; }; lg a[N]; string str; int n; bool cmp(lg a,lg b) { if(a....
bro
2026年2月9日 15:39
日志排序 题解:c++ ,这题空格很多,哪都是,还是直接分割吧
P1227
回复 0
|
赞 58
|
浏览 722
#include <bits/stdc++.h> using namespace std; struct Log{ string line; string date; double time; }; bool cmp(Log a,Log b){ if(a.time == b.time)return a.date < b.date; return a.time < b.time; } int main(...
langlang23
2026年1月21日 20:24
日志排序 题解: C++ , 存储整串,用 sstream 分解,输出
P1227
回复 1
|
赞 48
|
浏览 723
关键点: 1. istringstream 对 整串分割为 id date time consumeTime 对应四个参数 2. 耗时(consumeTime) 要存储为 double ,因为长度不固定,不能用字符串直接比较 3. 日期(date) 和时间(time) 可以拼接到一起,用字符串直接比较。 3.1 因为两个都是定长的,字符串按照字符(ASCII)表...
zxjrheaven
2025年3月23日 12:03
日志排序 题解:暴力(部分坑点有注释)
P1227
回复 0
|
赞 18
|
浏览 1.2k
#include <bits/stdc++.h> using namespace std; struct node { string zong; string name; string day; string sec; double tim; }fk[10005]; bool cmp(node a,node b) { i...
carrot_huan
2025年3月14日 23:54
日志排序 题解:正则表达式处理输入输出
P1227
回复 0
|
赞 7
|
浏览 1.2k
#include <algorithm> #include <string> #include <iostream> #include <vector> #include <regex> using namespace std; struct LogData { string original_line; string start_time; float total_time; ...
可可爱爱草莓派
2024年8月26日 16:51
日志排序 题解:75%通过写cmp用sort(a,a+n,cmp)
P1227
回复 1
|
赞 21
|
浏览 2.6k
#include<bits/stdc++.h> using namespace std; struct Log{ char name[12]; int y,month,d,h,minute,s,hs; double time; }stu[10100]; bool cmp(Log a,Log b){ if(a.time != b.time) return a.time < b.time; else if(a.y !=...
trmbh
2024年6月14日 23:02
完成率100%,字符串处理 + 排序(注意毫秒数和运行时间并不是字节序
P1227
回复 0
|
赞 81
|
浏览 3.1k
据我观察,这里有很多题解的完成率其实只有75%,这是为什么呢?因为他们都是将整个开始时间读作一个字符串,运行时间读作一个字符串,然后进行比较 这里有一个很坑的点,毫秒数和运行时间并不是字节序越小一定时间越早/短, 虽然前面的年月日时分秒由于格式固定这么说是没有错的; 但是对于毫秒数和运行时间,由于位数并不确定,像是字节序"40" > "355", 但是实际数值上上 40 < 355,这就会导致结果的错误 我这里采用了类 + sort排序, 进行了一个三层排序; 这里类中存一个整字符串,是因为拆了又合并,有两个...
nicooy
2024年2月26日 10:07
日志排序 题解:使用sort,将运行时间换为double
P1227
回复 1
|
赞 52
|
浏览 3.3k
将字符串输入,分割成两部分,为了方便输出,将name存储整个日志,将其中日期和时间分割出来。日期可以直接比大小 #include <iostream> #include <string> #include<algorithm> using namespace std; typedef struct T{ string name; string data; double run; }; bool cmp(T x,T y){ ...
老猫
2021年1月12日 22:27
还是sort
P1227
回复 2
|
赞 42
|
浏览 14.7k
定义一个类 将日志行拆分为 名称 时间 运行时间,然后进行排序 #include <bits/stdc++.h> using namespace std; struct T { string name; string time; string run; }t[10000]; bool compare(T t1,T t2) { if(t1.run ==t2.run ) return t1.time<t2.time; else return t1.run<t2.run; } int main() {...
1
2
题目
日志排序
题解数量
15
发布题解
在线答疑
热门题解
1
完成率100%,字符串处理 + 排序(注意毫秒数和运行时间并不是字节序越小一定时间越早/短)
2
日志排序 题解:c++ ,这题空格很多,哪都是,还是直接分割吧
3
日志排序 题解:使用sort,将运行时间换为double
4
日志排序 题解: C++ , 存储整串,用 sstream 分解,输出整串
5
还是sort
6
日志排序 题解:
7
日志排序 题解:75%通过写cmp用sort(a,a+n,cmp)
8
日志排序 题解:暴力(部分坑点有注释)
9
日志排序 题解:vector+sort 借鉴了同体解内的输入方式
10
日志排序 C语言题解:qsort排序