Not sure how to put my code in to excel.

1.#include <iostream>
2.using namespace std;
3.
4.int main()
5.{
6.    const int n = 20;
7.    int Array[n] = { 3, 5, 2, 9, 6, 12, 16, 11, 18, 4, 14, 8, 1, 15, 17, 7, 19, 13, 20, 10 };
8.
9.    cout << "Not sorted: \n";
10.    for (int i = 0; i < n; ++i)
11.    {
12.        cout << Array[i] << " ";
13.    }
14.
15.    cout << endl;
16.
17.    for (int i = 0; i < n; ++i)
18.    {
19.        for (int j = n - 1; j > i; --j)
20.        {
21.            if (Array[j] < Array[j - 1])
22.            {
23.                int temp = Array[j];
24.                Array[j] = Array[j - 1];
25.                Array[j - 1] = temp;
26.            }
27.        }
28.    }
29.
30.    cout << "Sorted: \n";
31.    for (int i = 0; i < n; ++i)
32.    {
33.        cout << Array[i] << " ";
34.    }
35.
36.    cout << endl;
37.
38.    system("pause");
39.    return 0;
40.}

If you don't mind me asking, why would you need to, given that Excel can sort a row or column of data with a single push of a button? I don't doubt you need it, I'm just looking for some background on the matter.

It is for a trace table, to show what it is doing

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.