putting variables into array

This is a discussion on putting variables into array within the C++ Programming forums, part of the General Programming Boards category; I need to sort a queue. So far I have created a queue containing 4 numbers, I then put these ...

  1. #1
    Unregistered
    Guest

    Question putting variables into array

    I need to sort a queue. So far I have created a queue containing 4 numbers, I then put these numbers into 4 variables (w, x, y and z). I was then going to put these variables into an array and sort the array. But I cant figure out how to put the contents of w, x, y and z into the array. Any suggestions.

    q.push(1);
    cout<<"the firt number in the queue is: "<<q.front()<<endl;
    q.push(0);
    cout<<"the second number in the queue is: "<<q.back()<<endl;
    q.push(3);
    cout<<"the thrid number in the queue is: "<<q.back()<<endl;
    q.push(2);
    cout<<"the fourth number in the queue is: "<<q.back()<<endl<<endl;

    //put items into variable
    w=q.front();
    q.pop();
    x=q.front();
    q.pop();
    y=q.front();
    q.pop();
    z=q.front();

  2. #2
    Registered User blight2c's Avatar
    Join Date
    Mar 2002
    Posts
    266
    i would do something like this

    Code:
    int array[max];
    int i;
    for(i=0,i<max;i++)
    {
    cout<<"enter number";
    cin>>array[i];
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. inputting integer array in a row recursevly..
    By transgalactic2 in forum C Programming
    Replies: 16
    Last Post: 01-21-2009, 10:05 PM
  2. Replies: 7
    Last Post: 11-25-2008, 01:50 AM
  3. putting int in my char array
    By waxydock in forum C Programming
    Replies: 13
    Last Post: 06-01-2007, 11:10 AM
  4. extracting data from file putting it into an array..
    By Cat00 in forum C++ Programming
    Replies: 4
    Last Post: 03-30-2005, 02:48 PM
  5. Merge sort please
    By vasanth in forum C Programming
    Replies: 2
    Last Post: 11-09-2003, 12:09 PM

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