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

  • SEARCH
  • Home
  • 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 7566833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:30:45+00:00 2026-05-30T14:30:45+00:00

I have a 2-dimensional array(3×7) with numbers between 0 to 20. I would like

  • 0

I have a 2-dimensional array(3×7) with numbers between 0 to 20. I would like to randomly change the locations, hence it is randomly rearranged. But it seems that every time it is run it has the same locations.

int arr[numRows][numCols] = {{0,1,2,3,4,5,6},{7,8,9,10,11,12,13},{14,15,16,17,18,19,20}};
random_rearrange_num(arr);
void random_rearrange_num(int p[][numCols])
{
  int temp = 0,k= 0,l = 0;
  for(int i = numRows -1 ; i > 0 ; i--)
  {
    for (int j = numCols-1;j>0; j--)
    {
          k = 0 + rand()/(RAND_MAX/(2-0+1)+1);
          l= 0 + rand()/(RAND_MAX/(6-0+1)+1);
          temp = p[i][j]; 
          p[i][j] = p[k][l];
          p[k][l] = temp;
    }
  }
}

I have shown the neccessary part in the question. The full code is here: https://codereview.stackexchange.com/questions/9419/programming-of-3-x-7-trick

For example: it always loads up with this first enter image description here

Second is this :

enter image description here

everytime i restart, the numbers are at the same location. How do i change it?

  • 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-30T14:30:47+00:00Added an answer on May 30, 2026 at 2:30 pm

    You should first initialize a seed with srand()

    A common way to seed is:

    srand (time(NULL));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a one dimensional array in VBScript that I would like to run
I have a two dimensional array of integers. I would like to write an
I have a 2 dimensional array of doubles I would like to display as
I have a 2 dimensional array, like so: char[,] str = new char[2,50]; Now,
I have a one-dimensional array of strings in JavaScript that I'd like to turn
i have multi dimensional array like below, Array ( [14289] => Array ( [0]
I have a two dimensional array like this $FrstArr = Array( [0]= array( [0]=>101,
I have a multi-dimensional array right now that looks like this: function art_appreciation_feeds() {
I have a multi-dimensional array that I'd like to use for building an xml
I have a 2-dimensional array of objects (predominantly, but not exclusively strings) that I

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.