当前位置:网站首页>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;
}
边栏推荐
- Raft agreement
- The mail function of LNMP environment cannot send mail
- Puzzle (016.3) is inextricably linked
- Preliminary summary of structure
- Zzuli:1049 square sum and cubic sum
- Luogu p4047 [jsoi2010] tribal division solution
- 7-18 finding the single root of polynomial by dichotomy
- 【7.3】146. LRU caching mechanism
- FPGA blocking assignment and non blocking assignment
- 光猫超级账号密码、宽带账号密码 获取
猜你喜欢

Sub GHz wireless solution Z-Wave 800 Series zg23 SOC and zgm230s modules

Zzuli:1053 sine function

【北大青鸟昌平校区】互联网行业中,哪些岗位越老越吃香?

retrofit

556. 下一个更大元素 III

Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)

Niuke: crossing the river

pyQt界面制作(登录+跳转页面)

Why is this error reported when modifying records in the database

表单文本框的使用(一) 选择文本
随机推荐
tonybot 人形机器人 查看端口并对应端口 0701
Adc128s022 ADC Verilog design and Implementation
Tiantu investment sprint Hong Kong stocks: asset management scale of 24.9 billion, invested in xiaohongshu and Naixue
Ultra simple mobile map development
dllexport和dllimport
洛谷P5194 [USACO05DEC]Scales S 题解
Zhejiang University Edition "C language programming (4th Edition)" topic set reference ideas set
Table of mathematical constants by q779
Find books ()
Tailing rushes to the scientific and Technological Innovation Board: it plans to raise 1.3 billion, and Xiaomi Changjiang is the shareholder
7-4 BCD decryption (10 points)
7-2 and then what time (15 minutes)
7-19 check denomination (solve binary linear equation)
retrofit
Why is this error reported when modifying records in the database
Happy capital new dual currency fund nearly 4billion yuan completed its first account closing
dllexport和dllimport
天谋科技 Timecho 完成近亿元人民币天使轮融资,打造工业物联网原生时序数据库
Timecho of Tianmou technology completed an angel round financing of nearly 100 million yuan to create a native timing database of the industrial Internet of things
洛谷P5018 [NOIP2018 普及组] 对称二叉树 题解