Questions tagged as 'random'

1
answer

Assign element to array only when space is available?

I have some vectors that I need to assign in a 20x20 array, but no vector can override the other and not be printed on different lines, they should be assigned vertically or horizontally. For example, I have the vectors: int a[8] ={1,2,3,4,5,6...
asked by 09.10.2015 / 06:31
1
answer

Draw of predefined values

I have two TextBox ( txtUM , txtDois ), and would like to make a draw of some preprogrammed date / string (Between the dates: 07: 55, 07:56, 07:57, 07:58, 07:59, 08:00, 08:01, 08:02, 08:03, 08:04, 08:05 ). > The number that was drawn would p...
asked by 20.04.2016 / 00:03
2
answers

Make arc4random () not repeat the last number

I created a app to generate random numbers. I just wanted him to not repeat the last number he showed. Example: the result was 9 (I execute the method that generates the random number again) The result was 9. I tried to cre...
asked by 05.08.2014 / 03:54
1
answer

Draw between user-defined options

Hello, I am creating a Petri Net simulator (I considered it a challenge since I am a beginner) and would like to know if there is a way to create a raffle between user-defined options. I would like to sort between, for example, 0, 2, 3 and 5 (th...
asked by 01.10.2017 / 05:26
1
answer

Even or odd through random module (Python)

Recently I started learning programming language with python, I created a classic "game" to learn with random.randint for the user to try to guess the number chosen by the machine. I tried to do the same but this time to guess if the computer...
asked by 20.10.2017 / 20:28
2
answers

Generate random numbers in java, store in a vector and sort them

I need to generate 100000 numbers, store them in a vector and sort them using the BubbleSort algorithm, the error "Exception in thread" main "java.lang.Error: Unresolved compilation problem: at testaSort.main(testaSort.java:8)" Code below:...
asked by 14.05.2017 / 03:43
2
answers

Generation of random numbers [duplicate]

I declare a method to generate random numbers, but the results are almost always the same, why? int geraAleatorio(int min, int max) { return ((rand() % (max - min)) + min) + 1; } Is there any other algorithm?     
asked by 25.02.2017 / 23:11
2
answers

List random objects

How could I generate random cars in the following model? would it be better to do this in the controller? class Pessoa < ActiveRecord::Base has_many :carros end     
asked by 26.09.2016 / 15:44
1
answer

Find element that ID is generated randomly

I have a situation that the id always keeps updating randomly ... and without an apparent orderimpossible I use find_element_by_id The component is as follows: <table id="treeview-2234-record-879" data-boundview="treeview-2234" data-reco...
asked by 18.01.2016 / 18:50
1
answer

Ruby on Rails - Randomize JSON variable and apply in Array

Well, I have a problem that is relatively simple, but that is ending with me. I have an array of JSON objects. This array of objects will compose another array containing other n arrays. So far so good. However, what happens is that with...
asked by 09.11.2015 / 22:42