GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — SortingAlgorithms/main.cpp at master · gleydson/SortingAlgorithms

Expand file tree

/

main.cpp

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
103 lines (92 loc) · 2.1 KB
/

main.cpp

Copy path

File metadata and controls

103 lines (92 loc) · 2.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <vector>
#include "libs/ed_sort.h"
// cores rgbcymkw
// red, green, blue, cyan, yellow, magenta, black, white
using namespace std;
void minimum_sort(vector<int> &vet)
{
for (int i = 0; i < (int)vet.size() - 1; i++)
{
for (int j = i + 1; j < (int)vet.size(); j++)
{
view_show(vet, {i, j}, "gy");
if (vet[j] < vet[i])
{
swap(vet[i], vet[j]);
view_show(vet, {i, j}, "yg");
}
}
}
}
void bubble_sort(vector<int> &vet)
{
int tam = vet.size();
int flag = 0;
for (int i = 0; i < tam; i++)
{
for (int j = flag; j < tam; j++)
{
view_show(vet, {i, j}, "gb");
if (vet[j] < vet[i])
{
view_show(vet, {i, j}, "rb");
swap(vet[i], vet[j]);
view_show(vet, {i, j}, "cb");
}
}
flag++;
}
}
void quick_sort(vector<int> &vet, int first, int final)
{
int i, j, pivot, center;
i = first;
j = final;
center = (first + final) / 2;
pivot = vet[center];
view_show(vet, {i, j, center}, "gbr");
while (i < j)
{
while (vet[i] < pivot)
{
i++;
view_show(vet, {i, j, center}, "gbr");
}
while (vet[j] > pivot)
{
j--;
view_show(vet, {i, j, center}, "gbr");
}
if (i <= j)
{
view_show(vet, {i, j, center}, "gbr");
std::swap(vet[i], vet[j]);
i++;
j--;
}
}
if (j > first)
quick_sort(vet, first, j);
if (i < final)
quick_sort(vet, i, final);
}
int main()
{
srand(time(NULL));
const int qtd = 70;
vector<int> vet(qtd, 0);
int min = 10;
int max = 400;
for (int i = 0; i < qtd; i++)
vet[i] = (rand() % (max - min + 1) + min);
view_set_bar();
view_set_faixa(0, qtd - 1);
// minimum_sort(vet);
quick_sort(vet, 0, vet.size());
// bubble_sort(vet);
view_lock();
return 0;
}
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.