Reading 2 diffrent lines into array

Hello there, I wrote a code that uses algorithm of bubble sorting, but it works only if I input one line (set) of numbers like:

4(how many numbers I want to sort) 45 6 78 12 <numbers to sort
3 45 67 12 <another example

Here is how input and output should look


INPUT:
6 3 4 1 2 6 5

6 8 2 2 6 4 3

OUTPUT:
3 1 4 2 6 5
3 1 2 4 6 5
3 1 2 4 5 6
1 3 2 4 5 6
1 2 3 4 5 6
result:
1 2 3 4 5 6

2 8 2 6 4 3
2 2 8 6 4 3
2 2 6 8 4 3
2 2 6 4 8 3
2 2 6 4 3 8
2 2 4 6 3 8
2 2 4 3 6 8
2 2 3 4 6 8
result:
2 2 3 4 6 8

And here is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>

using namespace std;

int main()
{
    bool changed = true;
    int size;
    int *tab = 0;
    tab = new int[size];

    cin >> size;
    tab[0] = size;

    cin.getline (tab,size);

    do
    {
        changed = false;
        for (int i = 1; i < size; ++i)
        {
                if (tab[i] > tab[i + 1])
                {
                    swap(tab[i], tab[i + 1]);
                    for (int p = 1; p <= size; p++)
                    cout << tab[p] << " ";

                    cout << "\n";
                    changed = true;
                }

        }

    }while(changed);

    cout << "result: \n";
    for (int p = 1; p <= size; p++)
    cout << tab[p] << " ";
}


INPUT/OUTPUT of my program

INPUT:
6 3 4 1 2 6 5

6 8 2 2 6 4 3

OUTPUT:
3 1 4 2 6 5
3 1 2 4 6 5
3 1 2 4 5 6
1 3 2 4 5 6
1 2 3 4 5 6
result:
1 2 3 4 5 6

It works when I put 2 lines in input but it calculates only first set, second is ignored. How to make it reading more than 1 set that user inputs? I can't find an answer since some days and it's eating me. Thanks for advance nad please use some easy strategy, some people were saying about vectors and stuff but I have no idea how to use it. Basically I want it to read each set of numbers put it into some array maybe? And then loop is doing job for each of arrays... How to make that?
Try a 2D array

int intArray[ 2 ][ 50 ]

This can then hold two sets of up to 50 different integers, you can then pass each set individually to a bubble sort function.

Also, it would be easier to not prompt the user for the number of integers in each list, instead let the user keep entering integers until a senital value is entered (like -1 for example).

If you don't know how to use 2D arrays, here's an article
http://www.cplusplus.com/forum/articles/7459/
The thing is I can get 2 or more maybe 6 or 4 sets to test, depends how an internal application wants to test my application. Also senital value isn't an option, I have to do it like it's shown. User input one set, and every new set in new line. Any other ideas?
Nevermind, solved this, topic to close.
Topic archived. No new replies allowed.