fork download
  1. #include <iostream>
  2. #include <ctime>
  3. #include <stdlib.h>
  4.  
  5. int main()
  6. {
  7. srand (time(NULL));
  8.  
  9. int nums[4] = {0 , 2, 3 ,5};
  10. int posicaoSorteada = rand() % 4;
  11. std::cout<<"Elemento sorteado "<<nums[posicaoSorteada];
  12.  
  13. return 0;
  14. }
  15.  
Success #stdin #stdout 0s 16048KB
stdin
Standard input is empty
stdout
Elemento sorteado 2