Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "lab1.h"
- #include "lab2.h"
- #include "lab3.h"
- #include "test.h"
- using namespace std;
- void countingSort(lab::Queue& q){
- int mx = INT_MIN;
- int size = q.size();
- for(int i = 0; i < q.size(); ++i){
- int front = q.front();
- mx = max(mx, front);
- q.pop();
- q.push(front);
- }
- auto count = vector<int>(mx + 1, 0);
- for(int i = 0; i < size; ++i){
- int front = q.front();
- count[front]++;
- q.pop();
- }
- for(int i = 0; i < count.size(); ++i){
- for(int j = 0; j < count[i]; ++j){
- q.push(i);
- }
- }
- }
- int main() {
- srand(time(nullptr));
- lab::Queue queue(20);
- for(int i = 0; i < queue.size(); ++i)
- queue.push(rand() % 10);
- queue.print();
- cout << endl;
- countingSort(queue);
- queue.print();
- }
- /*int main(){
- lab2::Graph G(4);
- set<int> visited;
- int cCount;
- cin >> cCount;
- for(int i = 0; i < cCount; ++i){
- string first_v, second_v;
- int weight;
- cin >> first_v >> second_v >> weight;
- G.Add_E(first_v, second_v, weight);
- }
- G.print();
- cout << endl;
- vector<string> ways = G.get_ways(8);
- for(int i = 0; i < ways.size(); ++i)
- cout << ways[i] << endl;
- return 0;
- }*/
- /*
- 5
- a b 3
- b d 5
- b c 5
- c d 1
- d a 7
- d e 2
- c e 6
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement