Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7691471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:37:55+00:00 2026-05-31T20:37:55+00:00

I need to generate an random array from a bigger array of int without

  • 0

I need to generate an random array from a bigger array of int without repetition and in a range of numbers.

For e.g
I have an array a[] with 1-200 int , What i need is random number array from all 200 int but of size 15.How could I implement this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:37:57+00:00Added an answer on May 31, 2026 at 8:37 pm
    Random rnd = new Random();
    
    int[] a = new int[200];
    for (int i = 0; i < a.length; i++)
        a[i] = i;
    
    int[] r = new int[15];
    for (int i = 0; i < r.length; i++) {
        int j = rnd.nextInt(a.length - i);
        r[i] = a[j];
        a[j] = a[a.length - i - 1];
    }
    

    That should do it. Random grab something from a. Once you’ve grabbed it, replace it with the “last” value of a. The “last” value is easily derived from a.length and i.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Like my question, i need to generate random numbers that have identical pairs between
I need to generate a random port number between 2000-65000 from a shell script.
I need to generate random numbers from Binomial(n, p) distribution. A Binomial(n, p) random
can anybody help me in making a method to generate random number without repetition
I need to generate a large list of random numbers from 600k to 2000k,
A specific example I need to generate a random number between 0 and 2,
I need to have a function which takes a 2D array and generates random
I need to generate a random pairs of numbers (floats) , within a certain
I am developing a program in which I need to generate a random number
I have an interval consisting of two float numbers, and need to generate 20

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.