diff --git a/aula3/main.cpp b/aula3/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7b864fe79f69802bd197a1248a64a08a99576e72 --- /dev/null +++ b/aula3/main.cpp @@ -0,0 +1,35 @@ +#include <iostream> +#include <cstdlib> + +int main(int argc, char* argv[]) { + if (argc <= 1) { + std::cout << "Usage: " << argv[0] << " <number of elements>\n"; + return -1; + } + + size_t n = std::atoi(argv[1]); + + + int* numeros = new int[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; + } + + } + } + + + delete[] numeros; +} +