Questions tagged as 'random'

2
answers

Assign numbers to phrases in PHP

Hello, I have a certain number of phrases, and I need every time the user sends a certain form, one of these phrases appears, using a random function, but I do not know how to start, I have no code so far.     
asked by 27.10.2015 / 12:05
2
answers

BubbleSort random numbers

The numbers are randomly generated in the vector, however when I call the bublle function to sort the result it returns 0. Can someone help me ???? using System; namespace BubbleSort_CSharp { class Program { static void Main(s...
asked by 26.11.2016 / 18:24
3
answers

Compiler accusing error that I do not know

#include<stdio.h> int sumofDie(int value1, int value2); int main( void ){ int die1[7]; int die2[7]; int i; srand(time(NULL)); printf("Rolling die 1 ..........\n"); for( i = 0; i < 6; i++){ int value; value = 1 + rand() % 6;...
asked by 05.01.2017 / 04:50
2
answers

Generate random numbers

I have the following problem: I need to generate a random number between 1 and 6 Assign a array of numbers if this new one is not contained in array If contained, regenerate. Do this process until the array of numbers has 6 numbers...
asked by 12.01.2016 / 12:14
1
answer

Problem generating random value using Random class

The program is generating a random value, but sometimes it pops the array, or simply does not display anything. Error examples: Mycode:importjava.util.Scanner;importjava.util.Random;publicclassSorteio{publicstaticvoidmain(String[]args){S...
asked by 13.09.2017 / 20:51
1
answer

How do I generate random numbers between 5 and 30 in Java?

I need to use the random method and store it in a distance variable, then show the distance from city A to city B, and city A to city D, that is, a different random number for each distance of THE. After creating the instances of the class City...
asked by 27.05.2017 / 18:20
2
answers

Number draw with exception

How do I sort a% number of% numbers in the C language in which I can exclude the possibility of drawing a certain number from my range given a given condition? Exemplifying in code: #include <stdio.h> #include <time.h> #include...
asked by 16.11.2016 / 17:11
2
answers

Refactoring random datetime generation (Python)

I accept suggestions to improve this code link import random import datetime def gen_timestamp(min_year=1915, max_year=1996): # gera um datetime no formato yyyy-mm-dd hh:mm:ss.000000 year = random.randint(min_year, max_year)...
asked by 25.10.2015 / 02:51
3
answers

Generate single random value with php

I need to generate a random value with letters and numbers in PHP, always starting with the letter A and having numbers and letters mixed with the value. It is referring to the "control code" field contained in this script: <?php requir...
asked by 23.04.2015 / 18:05
2
answers

How to generate Math.random starting from a value other than 0?

Personally, I just know the Math.random method and I already know how to generate values starting from 0 to another number by multiplication, eg Math.random () * 20. But I'm trying to do the same thing, starting from 5 to 20, I've already swe...
asked by 04.10.2014 / 07:16