Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- C++ basic template se distribuye bajo la licencia CREATIVE COMMONS
- "Attribution-NonCommercial 4.0 International"
- https://creativecommons.org/licenses/by-nc/4.0/
- ******************************************************************************/
- /*** Includes ***/
- // C++
- #include <cstdio>
- #include <iostream>
- #include <ctime>
- /*** Main ***/
- int main(int argc, char* args[]) {
- srand(time(NULL));
- int number[10];
- for (int i = 0; i < 10; i ++) number[i] = rand() % 1000;
- std::cout << "Unordered" << std::endl;
- for (int i = 0; i < 10; i ++) std::cout << number[i] << std::endl;
- std::cout << std::endl;
- int x;
- for (int a = 0; a < (10 - 1); a ++) {
- for (int b = (a + 1); b < 10; b ++) {
- if (number[b] < number[a]) {
- x = number[b];
- number[b] = number[a];
- number[a] = x;
- }
- }
- }
- std::cout << "Ordered" << std::endl;
- for (int i = 0; i < 10; i ++) std::cout << number[i] << std::endl;
- // Sal del programa con normalidad
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement