首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
cc12345
2025年3月17日 15:30
排序 题解:采用冒泡排序将奇数分在左边,偶数在右边,然后找到奇偶分界点
P1010
回复 0
|
赞 4
|
浏览 456
#include<bits/stdc++.h> using namespace std; bool cmp_up(int a,int b) { return a<b; } int main(){ int count; cin>>count; int num[count]; for(int i=0;i<count;i++) { cin>>num[i]; } for(int i=0;i<count-1;i++) { for(int j=0;j<count-1;j++) { i...
blackbook537
2025年3月15日 20:27
排序 题解:qsort
P1010
回复 0
|
赞 6
|
浏览 616
#include<stdio.h> #include<stdlib.h> int compare(const void *a, const void *b){ int num1 = *(int *)a; int num2 = *(int *)b; //先按奇偶排序 if(num1 % 2 == 0 && num2 % 2 != 0){ &n...
西电机试专家
2025年3月13日 21:24
排序 题解:棒棒算法
P1010
回复 0
|
赞 5
|
浏览 382
#include <bits/stdc++.h> using namespace std; bool cmp(int a,int b){//若返回值为ture,则a在前b在后,反之,顺序颠倒 if(a%2==1&&b%2==0) return 1; else if(a%2==0&&b%2==1) ...
诗岸梦行舟
2025年3月10日 14:22
排序 题解:笨蛋算法
P1010
回复 0
|
赞 7
|
浏览 604
#include<stdio.h> #include<stdlib.h> #include<string.h> int main(){ int n; scanf("%d",&n); int a[1001]; for(int i=0;i<n;i++){ scanf("%d",&a[i]); } int low=0; int high=n-1; while(low<high){ while(low<high&&a[high]%2==0) high--;...
jaygee_
2025年3月3日 09:13
排序 题解:
P1010
回复 0
|
赞 11
|
浏览 589
快速排序改比较方式 #include <bits/stdc++.h> using namespace std; const int N = 100005; int a[N]; bool cmp(int x, int y) { // 奇数在前,偶数在后 if (x % 2 != y % 2) { return x % 2 > y % 2; // 奇数优先 } // 同奇偶性时,按从小到大排序 return x < y; } void quickSort(int l...
chenxx
2025年2月28日 17:36
排序 题解:
P1010
回复 0
|
赞 4
|
浏览 447
#include <bits/stdc++.h> using namespace std; bool compare(const int& n1,const int& n2){ if((n1%2==1)&&(n2%2==0)) return true; else if((n1%2==0)&&(n2%2==1)) return false; else return n1<n2; } ...
MEGURI
2025年1月11日 20:38
排序 题解:拆分数组分别进行冒泡排序输出
P1010
回复 0
|
赞 27
|
浏览 838
#include<stdio.h> int main() { int n = 0; scanf("%d", &n); int i = 0; int j = 0; int k = 0; int x = 0; int a[1000]; &nbs...
hellokitty1679
2024年9月8日 14:59
排序 题解:C
P1010
回复 0
|
赞 10
|
浏览 2.2k
#include<stdio.h> #include<stdlib.h> int cmp (const void * a, const void * b) { return ( *(int*)a - *(int*)b ); } int main(void) { int a[1000],b[1000]; int X,n; int m=0,N=0; scanf("...
morning
2024年8月9日 21:57
排序 题解:运用自带sort函数+定义比较方法cmp解决
P1010
回复 0
|
赞 27
|
浏览 1.1k
#include<bits/stdc++.h> using namespace std; bool cmp(int a,int b){ if(a%2 != b%2)//不同奇偶 return a%2 > b%2; else return a<b; } int main(){ int n; cin>>n; ...
18919717626
2024年6月30日 15:26
排序 题解:sort
P1010
回复 0
|
赞 8
|
浏览 999
#include <iostream> #include <algorithm> using namespace std; const int N = 1010; int s[N]; int n; int main(){ cin >> n; for(int i = 0;i < n;i ++)cin >> s[i]; sort(s,s + n); for(int i = 0;i < n;i ++){ if(s[i] % 2 ){ cout <<...
1
2
3
...
5
题目
排序
题解数量
46
发布题解
在线答疑
热门题解
1
排序 题解:运用自带sort函数+定义比较方法cmp解决
2
排序 题解:拆分数组分别进行冒泡排序输出
3
排序 题解:
4
排序 题解:C
5
排序 题解:C++静态数组+sort()函数
6
排序 题解:sort
7
排序 题解:冒泡排序
8
排序 题解:笨蛋算法
9
排序 题解:
10
排序 题解:qsort