# 7-12 排序

### 输入格式:

/*
Author: Veeupup
排序
我们可以直接用 algorithm 下的 sort
还是推荐自己把快排可以再写一遍
*/
#include <cstdio>
#include <cstdint>
#include <algorithm>
using namespace std;

const int maxn = 1e5+5;

int n;
long arr[maxn];

// 复习快排
void quickSort(long *arr, int left, int right) {
if(left < right) {
int i = left, j = right;
long temp = arr[i];
while (i < j)
{
while(i < j && arr[j] > temp)
j--;
arr[i] = arr[j];
while(i < j && arr[i] <= temp)
i++;
arr[j] = arr[i];
}
arr[i] = temp;
quickSort(arr, left, i - 1);
quickSort(arr, i + 1, right);
}
}

int main()
{
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
scanf("%ld", &arr[i]);
}
// sort(arr, arr+n);
quickSort(arr, 0, n-1);
bool flag = false;
for (int i = 0; i < n; i++)
{
if(flag) {
printf(" %ld", arr[i]);
}else {
printf("%ld", arr[i]);
flag = true;
}
}
return 0;
}


# 7-13 工龄排序

/*
Author: Veeupup
*/
#include <cstdio>
#include <cstdint>
using namespace std;

const int maxn = 55;

int n, age[maxn];

int main()
{
freopen("data.txt","r", stdin);
fill(age, age + maxn, 0);
scanf("%d", &n);
int temp;
for (int i = 0; i < n; i++)
{
scanf("%d", &temp);
age[temp]++;
}
for (int i = 0; i < maxn; i++)
{
if(age[i] != 0) {
printf("%d:%d\n", i, age[i]);
}
}
return 0;
}


05-12 901

05-12 5808
12-18 91
09-24 802
12-15 1513
09-26 1474
07-16 2438
02-08 2300
11-06 456
01-22 78
12-16 1353
01-02 763
02-18 1103
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客