random

Rand () function does not return random numbers. C++

I have a function that needs to generate, in a specific part, a random number to do a certain task. But whenever the program ... e(itens_repetidos != 0); As seen in the code, I use the srand and rand functions to generate the number. What can be wrong?

How to generate large random numbers in C++?

I want to make a random number generator of [0,4], including those, only the problem is my teacher indicated that I use 4 mil ... )/4000000.0)*4); cout<<populacao[i]<<endl; aptidao[i]=populacao[i]; } system("Pause"); }

Generate random numbers in C?

I need to generate 5 random numbers in a range between -10 and +10. How could I do this ? I've seen that one can use shuffle, ... e if(num[i] < 0 ) { negativo += 1; } printf("\nPositivo(s) : %d ",positivo); printf("Negativo(s) : %d ",negativo);

Draw where the name cannot be drawn more than once

I need to make a Simple Sweepstakes software, but I don't know how to take the names that have been entered in the list box and draw one among them. The same name can not be drawn more than once. How to do this part?

How to generate random characters or strings?

How to specify the number of times a character can repeat? Ex: I have ABC , where C should repeat 4 times in a new 6-charac ... CC AC CB CC CB AC CC CB CB CC CC AB CC AB CC (no need is in that order, but must have all these outputs)

Generate random numbers that do not repeat

How can I generate a large sequence of random numbers that do not repeat? I have to generate 10 000 thousand numbers from 1 ... d( (unsigned) time(NULL)); for(i=1; i<10000; i++){ fprintf(fp, "%d\n", 1 + rand()% 999999); } fclose(fp); return 0; }

How to select by Bank the column value I used the random method()

I made a project on Android that is a hangman's game, where I can record the word and a hint in the SQLite database. In my Da ... rteada; } public static double random() { Random r = new Random(); return r.nextDouble(); } }

Random value in C++

I was practicing some C++, I created that simple dice game exercise, so I ran into a problem, How can I generate random value ... isualization (I do not use this tool much, so I do not know if it works with more than one file to make the cpp and header).

Randint does not generate random numbers the second time I use it

My randint when used the second time it does not generate new random numbers, it remains with the same numbers generated. I k ... ge(len(matriz)): for i in range(0, 3): print(matriz[c][i], end=' ') print(' ') print ('\n')

Guess a number, and in attempts, through the percentage show hints

I am trying to create a game where the user must determine a range and guess a random number that is generated within this ra ... not correspond to what I need to do, but I do not know which operations to insert so that it shows the answers as the table.

JAVA-generate a random & shuffled word

I intend to generate a random and shuffled word from a vector. At the moment it is already generating a random but not shuffl ... p; } return new String( a ); } public static void main (String[] args){ arrayword(); } }

Printing predefined sentences, randomly in C

Hello, I'm a beginner in programming and I'm learning to program in C. I want to make a program that has some sentences al ... ntire code, it is enough just to explain to me what is the best solution for the implementation of the part of the sentences.

Draw of numbers with exception

How do I draw a quantity n of numbers in the C language where I can exclude the possibility of drawing a certain number from ... if(x[i]==3){ x[i] = rand()% 8 ("com exceção do i"); } } } return 0; }

Distributing points evenly in a circle

I started making a code to randomly distribute points evenly in a circle, however, by generating a point located with a rando ... he points are evenly distributed: Pontos = R * sqrt(rand(1,N)) .* exp(j * 2 * pi * rand(1,N)); How can this be explained?

Dynamic/stochastic allocation of objects in QML

I am currently trying to do the following in qml, simultaneously: Do dynamic loading of previously created objects a se ... gest, if you are interested, to consult the link below: Https://github.com/tiagmoraismorgado/TMM_QML_UI_UX_FRAMEWORK_WIP

Which means assign Math.random ()> 0.5 to a variable?

What Does Math.random() > 0.5; mean in a boolean? Here is an example: class Pro { public static void main(String[] ... length; i++) { array[i] = Math.random() > 0.5; System.out.print(array[i] + "\t"); } } }

Manipulating odds with JS when using Math.random ()?

When using this function Math.floor((Math.random() * 10) + 1) i get a random number from 1 to 10. We assume that each number ... d 30% chance of getting an even number. is it possible to do this? What would be the logic applied and how can I do it?

How to open a random image

I have a new doubt and this has been the best place to find answers, since Ja agradeco. My problem and the following, I am do ... te('width', '200px'); document.body.appendChild(oImg); } Is there any way to achieve this??? Thank you very much

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

How to generate a random number between two numbers in Java? [duplicate]

this question already has answers here : ... ber in specific java between min and max? Because with the nextInt function of the Random Class you can only specify the max.