“Angka acak” Kode Jawaban

menghasilkan nomor acak

public int getRandomNumber(int min, int max) {
    return (int) ((Math.random() * (max - min)) + min);
}
Amused Alligator

Angka acak

function randomInteger(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
}
Disturbed Duck

generator angka acak

// C program to generate random numbers
#include <stdio.h>
#include <stdlib.h>
#include<time.h>
 
// Driver program
int main(void)
{
    // This program will create different sequence of
    // random numbers on every program run
 
    // Use current time as seed for random generator
    srand(time(0));
 
    for(int i = 0; i<4; i++)
        printf(" %d ", rand());
 
    return 0;
}
Stupid Sandpiper

angka acak

import random                                    # Import random libary
minimum = 1                                      # Minimum number
maximum = 10                                     # Maximum number
random_number = random.randint(minimum,maximum)  # Generate random number
print(random_number)                             # Print random number
Courageous Cardinal

Angka acak

    System.out.println(Math.random());  
Javasper

Jawaban yang mirip dengan “Angka acak”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya