資料結構實驗之排序三:bucket sort 桶排序
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false);//用c++讀入超時 int n; cin>>n; int i,a[101],x; memset(a,0,sizeof(a)); for(i = 0;i <= n - 1;i++) { cin>>x; if(x > 100) x = 100; a[x]++; } for(i = 0;i <= 100;i++) { if(a[i] != 0) { cout<<i<<" "<<a[i]<<endl; } } return 0; }
相關推薦
資料結構實驗之排序三:bucket sort 桶排序
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false);//用c++讀入超時 int n; cin>>n
二叉排序樹的應用之——資料結構實驗之查詢三:樹的種類統計
注意:中序遍歷二叉樹時,只能在樹不為空的時候才能進行遞迴呼叫! 資料結構實驗之查詢三:樹的種類統計 Time Limit: 400 ms Memory Limit: 65536 KiB Submit Statistic Problem Descr
資料結構實驗之陣列三:快速轉置(std::stable_sort函式)
資料結構實驗之陣列三:快速轉置 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Description 轉置
SDUTOJ3311資料結構實驗之串三:KMP應用
資料結構實驗之串三:KMP應用 (PS:這題巨坑 嗚嗚嗚。。) https://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Contest/contestproblem/cid/2710/pid/3311 Time Limit:&nbs
資料結構實驗之串三:KMP應用
Problem Description 有n個小朋友,每個小朋友手裡有一些糖塊,現在這些小朋友排成一排,編號是由1到n。現在給出m個數,能不能唯一的確定一對值l和r(l <= r),使得這m個數剛好是第l個小朋友到第r個小朋友手裡的糖塊數? Input 首先輸入一
資料結構實驗之查詢三:樹的種類統計(SDUT 3375)
C: #include <stdio.h> #include <stdlib.h> #include <string.h> struct node { char data[30]; struct node *lc; struct n
SDUT3375資料結構實驗之查詢三:樹的種類統計
剛AC的新鮮程式碼,馬上給安排過來 用的還是***二叉排序樹***的知識,只不過比較的物件由數字變成了字串,而每個節點有多加了一個記錄物件也就是每一種樹的數量data #include <iostream> #include <cstring> #include
day2——資料結構實驗之串三:KMP應用
資料結構實驗之串三:KMP應用 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 有n個小朋友,每個小朋友手裡有一些糖塊,現在這些小朋友排成一排,編號是由1到n。現在給出m個數,能不能唯一
資料結構實驗之陣列三:快速轉置
題目描述 轉置運算是一種最簡單的矩陣運算,對於一個m*n的矩陣M( 1 = < m < = 10000,1 = < n < = 10000 ),它的轉置矩陣T是一個n*m
資料結構實驗之棧三:字尾式求值 SDUT 2133
題目描述 對於一個基於二元運算子的字尾表示式(基本運算元都是一位正整數),求其代表的算術表示式的值。 輸入 輸入一個算術表示式的字尾式字串,以‘#’作為結束標誌。 輸出 求該字尾式所對應的算術表示式的
資料結構實驗之串三:KMP應用 sdut(oj 3311)
資料結構實驗之串三:KMP應用 Time Limit: 1000ms Memory limit: 65536K 有疑問?點這裡^_^ 題目描述 有n個小朋友,每個小朋友手裡有
資料結構實驗之排序三:bucket sort (SDUT 3400)
桶排序: #include <stdio.h> #include <string.h> int a[5555555]; int main() { int n,m; scanf("%d",&n); memset(a,0,sizeof
SDUT3400資料結構實驗之排序三:bucket sort
此題限時,如果用的c++的話,用cin輸入相對於scanf會消耗更多的時間,消除的方式是在main()函式開始的時候加上一句 ios::sync_with_stdio(false); 這樣可以使cin和scanf的效率相差甚小。 如果用c則木有這個問題 #include <io
C語言 資料結構排序與查詢 資料結構實驗之排序三:bucket sort
資料結構實驗之排序三:bucket sort Time Limit: 250MS Memory Limit: 65536KB Submit Statistic Problem Description 根據人口普查結果,知道目前淄博市大約500萬人口,你的
資料結構實驗之查詢一:二叉排序樹 (SDUT 3373)
二叉排序樹(Binary Sort Tree),又稱二叉查詢樹(Binary Search Tree),也稱二叉搜尋樹。 #include <stdio.h> #include <string.h> #include <stdlib.h> struct nod
SDUT3374資料結構實驗之查詢一:二叉排序樹
判斷是否為同一棵二叉排序樹 解決這個問題需要兩步: 1.建立二叉排序樹 2.判斷兩棵樹是否相同 詳情看程式碼和註釋,懶人程式碼 #include <iostream> #include <cstring> using namespace std; type
資料結構實驗之查詢四:二分查詢__Find
Time Limit: 30 ms Memory Limit: 65536 KiB Problem Description 在一個給定的無重複元素的遞增序列裡,查詢與給定關鍵字相同的元素,若存在則輸出找到的位置,不存在輸出-1。 Input 一組輸入資料,輸入資料第一行首先輸入兩
資料結構實驗之查詢七:線性之雜湊表
Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 根據給定的一系列整數關鍵字和素數p,用除留餘數法定義hash函式H(K
資料結構實驗之查詢五:平方之雜湊表 (SDUT 3377)
Hash表的平方探測思路:如果當前這個沒存放數值,就放進去,如果當前這個地方Hash [ i ] 已經有數值了,就以平方的間隔左右尋找沒有存放數的空白 Hash [ i ]。 #include <bits/stdc++.h> using namespace std;
資料結構實驗之查詢六:順序查詢(SDUT 3378)
(不知道為啥開個陣列就 TLE 。QAQ) #include <stdio.h> #include <stdlib.h> #include <string.h> //const int maxn = 100005; // //int a[ma