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

  1. #1
    Registered User
    Join Date
    Jul 2005

    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.
    for(int i=0;i<20;++i) {
        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:

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

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Word of advice: we dont like blatently helping people with homework. We'll give you hints, but we wont do the work for you.

  3. #3
    Registered User
    Join Date
    Jul 2005


    I could not do the part of storing the unique number in arrays (using sequential search). I really cannot understand that part, can anyone help me to code that part, and i will continue from there and finish my work on my own.

  4. #4
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Start by reading a tutorial or a sorting algorithm?

  5. #5
    Registered User
    Join Date
    Jul 2005

    help needed

    I cannot understand sequential search.

    How do i store the unique random numbers (without duplicate), compare the first element with every element and store it, and if the element is equals to any of it, dont store it, but how to do that, any clue, please help?

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    I cannot understand sequential search.
    Ever tried flipping through a pile of notes page by page to find the page you want?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

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, 05:23 PM
  4. Another brain block... Random Numbers
    By DanFraser in forum C# Programming
    Replies: 2
    Last Post: 01-23-2005, 05:51 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM