Storing random number in array(sequential search & bubble sort)

This is a discussion on Storing random number in array(sequential search & bubble sort) within the C++ Programming forums, part of the General Programming Boards category; i have generate random number, 1 - 20, such a sequence may or may not contain duplicates. Print each number ...

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    4

    Storing random number in array(sequential search & bubble sort)

    i have generate random number, 1 - 20, such a sequence may or may not contain duplicates. Print each number as it is generated, and store it in an array, but only if it is not a duplicate of a number already stored.
    Code:
    for(int i=0;i<20;++i) {
        randomInt=rand()%20+1;
        cout<<randomInt<<endl;  // print each number
            
        MyRand[i]=randomInt;  //how to store all unique number 
     // (no  duplicates in a one-dimensial array
    // (use sequential search) 
     // - Use a function to search the existing array 		  
            }
    
      // After you have created the array, print it along with its
    // actual size - Use a function to print the array.
    
    // Then print the array again, this time in sorted in increasing  
    //order - Use a function to sort the array (use bubble sort)
    Please can anyone guide me into successfull coding. I need this ASAP, coz the due date is near. Please help, i am beginner , i am trying to learn. E-mail me at: joeraj7@yahoo.com

    Anyone can help, please give me your MSN. ok. THX alot.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    1 thread per topic please

    All replies to Storing random number in array(sequential search & bubble sort)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue w/ Guess My Number Program
    By mkylman in forum C++ Programming
    Replies: 5
    Last Post: 08-23-2007, 01:31 AM
  2. Psuedo random numbers in a bubble sort.
    By Sir Andus in forum C++ Programming
    Replies: 10
    Last Post: 04-09-2007, 08:25 PM
  3. non repeating random number generation?
    By gencor45 in forum C# Programming
    Replies: 1
    Last Post: 02-08-2005, 04:23 PM
  4. Another brain block... Random Numbers
    By DanFraser in forum C# Programming
    Replies: 2
    Last Post: 01-23-2005, 04:51 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21