首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
zhangs
2025年3月19日 12:58
大整数排序 题解:
P1412
回复 0
|
赞 2
|
浏览 393
//c语言字符串模拟数字 #include <stdio.h> #include <stdlib.h> //比较大小函数 int cmp(char* s1,int len1,char* s2,int len2){ //1比2大输出1,2比1大输出2,一样大输出0 if(len1>len2) return 1; else if(len1<len2) return 2; e...
zxjrheaven
2025年3月15日 11:17
大整数排序 题解:暴力
P1412
回复 0
|
赞 3
|
浏览 483
#include <bits/stdc++.h> using namespace std; bool cmp(string a,string b) { if(a.length()!=b.length()) { return a.length() < b.length(); } return a<b; } int ...
GENARDING
2025年3月13日 11:22
vector秒了,简简单单
P1412
回复 0
|
赞 4
|
浏览 411
#include<bits/stdc++.h> using namespace std; bool cmp(string a, string b){ if (a.length() != b.length()) { return a.length() < b.length(); // 长度小的字符串对应的数字较小 } return a < b; // 长度相等时,逐字符比较 } int main(){ int n; while(cin >> n){ ...
shiv15832
2025年3月11日 00:05
大整数排序 题解:卡80%原因
P1412
回复 0
|
赞 3
|
浏览 459
卡80卡了半天,没看见多组输入,多组输入数据一定要用while(cin >> n)这样的格式。 本题思路其实很简单,字符串长度一样,直接字典排序,用sort就可以解决,但长度不一样eg:333和11111111111,字典排序很明显11111111要更小,所以长度不一样就输出短的。数据类型不用说肯定是string,因为int会超限。 代码:有些繁琐,写的随心所欲了 #include<bits/stdc++.h> using namespace std; typedef struct{ string sc...
可可爱爱草莓派
2024年8月27日 18:26
写复杂了
P1412
回复 1
|
赞 0
|
浏览 1.7k
#include<bits/stdc++.h> using namespace std; struct Big{ string num; int len; }big[110]; bool cmp(Big a,Big b){ return a.len < b.len; } int main(){ int n; while(cin >> n){  ...
西电机试专家
2025年2月9日 12:09
大整数排序 题解:马+7超绝简单易懂思路无敌坤坤打篮球版
P1412
回复 0
|
赞 19
|
浏览 562
#include <bits/stdc++.h> using namespace std; //思路:利用string的排序,若字符串长度相同,则根据ASCII排序, // 否则,长的元素更大 bool cmp(string a,string b){ if(a.size()==b.size()) &nbs...
红鲤鱼
2025年2月7日 16:32
大整数排序 题解:
P1412
回复 0
|
赞 6
|
浏览 570
用字符串类型存储,int型不够存,比较时,先比较字符串长度,长度更长的更大,长度相等则比较字符串。 #include <bits/stdc++.h> using namespace std; bool cmp(string a,string b){ if(a.length()==b.length()) return a<b; return a.length()<b.length(); } int main(){ int n; while(cin>>n){ string *s=n...
huanghu
2024年3月21日 09:56
大整数排序 题解:大整数排序
P1412
回复 1
|
赞 5
|
浏览 2.3k
#include<stdio.h> #include<iostream> #include<string> #include<algorithm> using namespace std; bool cmp(string s1, string s2){ if(s1.length() < s2.length()){ return true; } else if(s1.length() > s2.length()){ return false; }else{ return s1&l...
Candour
2024年6月9日 17:13
大整数排序(大数问题用python)题解:
P1412
回复 0
|
赞 2
|
浏览 637
while True: try: N = int(input()) nums = [] for i in range(N): x = int(input()) nums.append(x) nums.sort() for num in nums: print(num) except: break
Mihara
2022年6月12日 15:40
大整数看作字符串
P1412
回复 1
|
赞 3
|
浏览 5.7k
自定义排序即可: 数字位数多的一定大于位数少的; 位数相同,从头到尾比较各个数字位、直到找到一个二者间更大的即可。 #include <string> #include <algorithm> #include <iostream> using namespace std; // 求大整数升序排序的结果 bool cmp(string a, string b) { if (a.size() == b.size()) { for (int i = 0; i < ...
1
2
题目
大整数排序
题解数量
17
发布题解
在线答疑
热门题解
1
大整数排序 题解:马+7超绝简单易懂思路无敌坤坤打篮球版
2
大整数排序 题解:
3
大整数排序 题解:大整数排序
4
vector秒了,简简单单
5
题解:大整数排序
6
大整数排序 题解:卡80%原因
7
字符串排序(重写cmp)
8
大整数看作字符串
9
大整数排序 题解:暴力
10
大整数排序(大数问题用python)题解: