当前位置:网站首页>Bucket sorting in C language
Bucket sorting in C language
2022-07-03 14:36:00 【roseisbule】
When we're dealing with it c When de duplication of super large data in language , The running efficiency of the program will be very low , The running memory will be very large .

Such as this topic , The background gives a huge amount of data , If we write ordinary counting and sorting functions, we will not be able to process these data , So we need to find a stronger idea .
Our normal method is , Create an array , Store every element , But this will cause the array to be very large . So we changed our mind , Use subscripts to store data , Let the element content store the number of occurrences of this small mark , It's easy to solve . The code is as follows .
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#define NUM 500000
int main()
{
int arr[NUM] = { 0 };
int num = 0;
int tmp = 0;
scanf("%d", &num);
for (; num >0; num--)
{
tmp = 0;
scanf("%d", &tmp);
arr[tmp]++;
}
for (num = 0; num < NUM; num++)
{
if (arr[num] != 0)
printf("%d ", num);
}
return 0;
}
边栏推荐
- US stock listing of polar: how can the delivery of 55000 units support the valuation of more than 20billion US dollars
- Bibit pharmaceutical rushed to the scientific innovation board: annual revenue of 970000, loss of 137million, proposed to raise 2billion
- Although not necessarily the best, it must be the hardest!
- Too many files with unapproved license
- Use of constraintlayout
- 7-22 tortoise and rabbit race (result oriented)
- 556. 下一个更大元素 III
- dllexport和dllimport
- pyQt界面制作(登录+跳转页面)
- Strategy, tactics (and OKR)
猜你喜欢

Code writing and playing method of tonybot humanoid robot at fixed distance

Dllexport et dllimport

556. The next larger element III

7-15 calculation of PI

Tonybot humanoid robot checks the port and corresponds to port 0701

Tiantu investment sprint Hong Kong stocks: asset management scale of 24.9 billion, invested in xiaohongshu and Naixue

天谋科技 Timecho 完成近亿元人民币天使轮融资,打造工业物联网原生时序数据库

剑指 Offer 28. 对称的二叉树

Doris学习笔记之数据表的创建

Creation of data table of Doris' learning notes
随机推荐
NPM install is stuck with various strange errors of node NPY
7-6 mixed type data format input
Luogu p4047 [jsoi2010] tribal division solution
【7.3】146. LRU缓存机制
别再问自己适不适合做软件测试了
7-17 crawling worms (break exercise)
etcd集群权限管理和账号密码使用
Mongodb index
Sub GHz wireless solution Z-Wave 800 Series zg23 SOC and zgm230s modules
tonybot 人形機器人 紅外遙控玩法 0630
Pyqt interface production (login + jump page)
Zzuli:1055 rabbit reproduction
适用于XP的DDK
Although not necessarily the best, it must be the hardest!
pyQt界面制作(登录+跳转页面)
Adc128s022 ADC Verilog design and Implementation
分布式事务(Seata) 四大模式详解
7-24 reduction of the simplest fraction (rolling Division)
tonybot 人形机器人 查看端口并对应端口 0701
US stock listing of polar: how can the delivery of 55000 units support the valuation of more than 20billion US dollars