CCF考试认证模拟练习——数字排序
2024-08-25 14:01:28
#include<iostream>
#include<algorithm>
using namespace std;
struct node
//定义结构体
{
int num;//数据
int count;//出现的次数 计数
};
bool cmp(node a, node b)//排序
{
if (a.count != b.count)
return a.count>b.count;
return a.num<b.num;
}
node a[1005];
//node temp;
int main()
{
int n,x,i;
for ( i = 0; i <= 1000; ++i)
{
a[i].num = i;
}
cin >> n;
for (i = 1; i <= n; ++i)
{
cin >> x;
++a[x].count;
}
sort(a, a + 1005, cmp);
for ( i = 0; i <= n; ++i)
{
if (a[i].count == 0)
break;
cout << a[i].num << " " << a[i].count << endl;
}
return 0;
}
最新文章
- 杭电--1102--Constructing Roads--并查集
- (转)JS产生随机数的几个用法!
- 区分各浏览器的CSS hack(包括360、搜狗、opera)
- python入门综合
- ASP.NET WebAPI 08 Message,HttpConfiguration,DependencyResolver
- linux下系统对于sigsegv错误时的处理
- 在Salesforce中调用外部系统所提供的的Web Service
- 第一个jsp代码实现简单计算器
- BZOJ-4424 &;&;CodeForces-19E Fairy DP+dfs (Link-Cut-Tree可A)
- Objective-C 【关于导入类(@class 和 #import的区别)】
- SVN 中trunk、tags、branches使用
- DBA查询命令积累——不断更新
- PKU 1509 Glass Beads (最小表示法)
- 再起航,我的学习笔记之JavaScript设计模式03
- TF-IDF特征选择
- 【batch】批处理文件多参数处理和for循环字符串连接
- 金山wps面经
- 配置SQL Server 2016无域AlwaysOn(转)
- English trip M1 - AC3 Teacher:Corrine
- java集合框架图
热门文章
- springcloud干货之服务消费者(ribbon)
- 本地idea调试spark2.x程序
- LeetCode 238. Product of Array Except Self (去除自己的数组之积)
- Python中如何防止sql注入
- Ceph: A Scalable, High-Performance Distributed File System译文
- PhiloGL学习(6)——深情奉献:快乐的一家
- Vue源码学习02 初始化模块init.js
- Install a Redmine on Ubuntu system
- virualbox 搭建 otter
- 使用OpenCV训练Haar like+Adaboost分类器的常见问题