From 73fea657c750f99261b275d7fc3246cf859fdff4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Waldson=20Patr=C3=ADcio?= <waldsonpatricio@gmail.com>
Date: Thu, 20 Feb 2020 20:30:22 -0300
Subject: [PATCH] =?UTF-8?q?Aula=202=20-=20Cria=20um=20array=20com=20N=20el?=
 =?UTF-8?q?ementos=20aleat=C3=B3rios,=20ordena-os=20e=20imprime?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 aula2/main.cpp | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 aula2/main.cpp

diff --git a/aula2/main.cpp b/aula2/main.cpp
new file mode 100644
index 0000000..1954cf1
--- /dev/null
+++ b/aula2/main.cpp
@@ -0,0 +1,33 @@
+#include <iostream>
+#include <cstdlib>
+
+int main(int argc, char* argv[]) {
+    size_t n = 2500000;
+
+    // 1. usar a free store (new e delete)
+    // 2. receber o N pelo argv (atoi)
+    int numeros[n];
+
+    for (size_t i = 0; i < n; ++i) {
+        numeros[i] = rand() % 100;
+    }
+
+    //ornedar
+
+    for (size_t i = 0; i < n - 1; ++i) {
+        for (size_t j = i + 1; j < n; ++j) {
+            if (numeros[j] < numeros[i]) {
+                int tmp    = numeros[j];
+                numeros[j] = numeros[i];
+                numeros[i] = tmp;
+            }
+
+        }
+    }
+
+
+    for (size_t i = 0; i < n; ++i) {
+        std::cout << numeros[i] << "\n";
+    }
+}
+
-- 
GitLab