Semana 07
Alguns exemplos de problema são:
C++:
#include <algorithm> // inclusão da rotina sort. #include <vector> #include <cstring> using namespace std; vector<int> intVec = {56, 32, -43, 23, 12, 93, 132, -154}; vector<string> stringVec = {"John", "Bob", "Joe", "Zack", "Randy"}; // Ordenação do vetor de inteiros sort(intVec.begin(), intVec.end()); // Ordenação do vetor de strings sort(stringVec.begin(), stringVec.end());
#include <algorithm> // inclusão da rotina sort. using namespace std; int v[] = {56, 32, -43, 23, 12, 93, 132, -154}; // Ordenação do vetor de inteiros sort(v,v+8);
Java:
import java.util.Arrays; int[] intArray = {56, 32, -43, 23, 12, 93, 132, -154}; // Ordenação do vetor de inteiros Arrays.sort(intArray);
import java.util.ArrayList; import java.util.Collections; List
otherEx = new ArrayList(); otherEx.push( 56); otherEx.push( 32); otherEx.push(-43); otherEx.push( 23); // Ordenação do vetor de inteiros Collections.sort(otherEx);
Python:
intArray = [56, 32, -43, 23, 12, 93, 132, -154];
# Ordenação do vetor de inteiros
intArray.sort();
Leitura:
Exercícios:
Semana 07