BUBBLE SORT PLEASE HELP

Im trying to use a bubble sort with a 2-d array
my code reads the array but im getting a error at the bottom
invalid conversion from int to int...i have no clue y....heres my code

#include <iomanip>
#include <cmath>
#include <ctime>
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
const int N = 5;
const int K = 4;
const int START = 0,END = 20,SIZE = 30;
int **A;
A=new int *[N];
int temp;
int i,j;

ifstream infile ("BS.DAT");
cout<<"Matrix A"<<endl;
cout<<endl;
for (int i=0; i<N; i++)//generates the matrix A
{
A[i]= new int [N];
}

for (int row=0; row<N; row++)
{
for (int col=0; col<K; col++)
{
infile >>A[row][col];

}
//cout<<endl;
}
for (int row=0; row<N; row++)
{
for (int col=0; col<K; col++)
{
cout<<setw(10)<<A[row][col];

}
cout<<endl;



}
infile.close();
for (i = START; i <END;i++)
{
for (j = START;j<END-i-1;j++)
{
if (A[j] > A[j+1])
{
temp = A[j+1];
A[j+1] = A[j];
A[j] = temp;
}
}
}
system("pause");
return 0;
}




heres the file BS.DAT
3 33 333 3333 5 55 555 5555 1 11 111 1111 4 44 444 4444 2 22 222 2222


the output should look like this
5 55 555 5555
4 44 444 4444
3 33 333 3333
2 22 222 2222
1 11 111 1111


and then like this

1111 111 11 1
2222 222 22 2
3333 333 33 3
4444 444 44 4
5555 555 55 5
try changing
temp = A[j+1]; to temp = *A[j+1];
and then
*A[j] = temp
Last edited on
Topic archived. No new replies allowed.