- 博客(8)
- 收藏
- 关注
原创 洛谷1036 选数
洛谷1036 选数#include<iostream>using namespace std;const int N = 21;int a[N];int n, k;long long res;int ifprime(int a)//素数判断 { for(int i = 2; i * i <= a; i ++)//也可用sqrt,头文件#include<math.h> { if(a % i == 0) return 0; } return
2021-04-20 21:18:43
223
原创 洛谷1104 生日
洛谷1104 生日#include<iostream>#include<string>#include<algorithm> using namespace std;const int N = 110;int n;struct student{ string s; int num; int y; int m; int d;}stu[N];bool cmp(student a,student b){ if(a.y != b.y) re
2021-04-20 20:13:29
111
原创 洛谷1116 车厢重组
洛谷1116 车厢重组#include<iostream>using namespace std;const int N = 10010;int a[N];int n, t, k = 0;int main(){ cin >> n; for(int i = 0; i < n; i ++) cin >> a[i]; for(int i = n - 1; i >= 0; i --) { for(int j = 0; j <
2021-04-20 19:57:21
76
原创 洛谷1093 奖学金
洛谷 1093 奖学金#include<iostream>#include<algorithm>using namespace std;const int N = 310;int score[N][3];int n;struct Total{ int num;//学号 int s;//总分 int score[3];//三门课程成绩 } t[N];//结构体 bool cmp(Total a, Total b){ if(a.s != b.s) re
2021-04-20 19:34:56
167
原创 堆排序
堆排序#include<iostream>using namespace std;const int N = 100010;int a[N];void BigHeap(int a[], int parent, int n){ int k = a[parent]; //k记录当前的一个父节点值 for(int j = 2 * parent; j <= n; j *= 2) //j为当前父节点的左孩子节点 { if(j < n &&
2021-04-14 19:36:17
36
原创 桶排序
桶排序#include<iostream>using namespace std;const int N = 100010;int a[N] = {0}; int n, k;int main(){ cin >> n; for(int i = 0; i < n; i ++) { scanf("%d", &k); a[k] ++; } for(int i = 0; i < N; i ++) { if(a[i] != 0)
2021-04-12 19:14:43
44
原创 选择排序2021-04-12
选择排序#include<iostream>using namespace std;const int N = 100010;int a[N];int n;int main(){ cin >> n; for(int i = 0; i < n; i ++) scanf("%d", &a[i]); for(int i = 0; i < n; i ++) { int k = i; for(int j = i + 1; j < n
2021-04-12 18:44:01
72
原创 希尔排序
希尔排序#include<iostream>using namespace std;int n, i, j, d, temp;void shellsort(int a[], int dk){ for(i = dk; i < n; i ++) { if(a[i-dk] > a[dk]) { temp = a[i]; for(j = i - dk; j >= 0 && a[j] > temp; j = j - dk) a[j
2021-04-12 18:05:14
48
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人