2-dimentinal arrays with decreasing user input

Hi. I'm new here.

I have this assignment. I have to create a table with two columns named Part No and Quantity. Then user have to key in any numbers but must be less than or equal 100 for both part no and quantity. later, the prog will make the quantity numbers in decreasing value.

for example:
Part No | Qty
12 | 10
9 | 19
201 | 8

then C++ will change it to

Part No | Qty
9 | 19
12 | 10
201 | 8

I have done until user input. but I dont know on how to make it in decreasing order.

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
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
    int i, j, a, d, how, val[a][d];
    
    cout << "How many PartNo and Quantity?" << endl;
    cout << "\t:"; cin >> how;
    
    int NUMROWS = how;
    int NUMCOLS = how;
    
    cout << "\nPart No | Quantity";
    
    for (i = 0; i < NUMROWS; i++)
    {
        cout << endl; 						
        for (j = 0; j < NUMCOLS; j++)
        {
            cin >> val[i][j];
            
            }
            }
            cout << endl;
            
            return 0;
            } 


plus, how I want the val[i][j] be in parallel? because when user input value, it will go downward. Btw, those lines in between those numbers in the examples in not necessaries. I just want to make it clear for you guys.
Last edited on
Topic archived. No new replies allowed.