Int Array trouble



#include<iostream>
#include<string>

const int MAX_A = 3;
const int MAX_B = 4;
//declare two dimensional array
int numbers[MAX_A][MAX_B];


int main()
{
// declaring variables
using namespace std;
int MAX_A = 3;
int MAX_B = 4;
int numberArray[3][4];
// asking the user to input data & storing in array
cout << "This program will take the user's input and store into an array." << endl;
cout << "Please enter any number, up to a series of 12 numbers..." << endl;
// declaring two-demensional array


for (int i=0; i < MAX_A; i++)
{
for (int j=0; j < MAX_B; j++)
{
while(1) // keep trying until we get a valid input
{
cout<<"Enter a number: "<<endl;
cin>>numberArray[i][j];
if (!cin)
{
cout << "Please enter a real, positive number." << endl;
// clean up the stream to remove the everything entered up to that point
}
else
break; // if we got a number, break the innermost loop
} // error checking loop
} // MAX_B loop
} // MAX_A loop
// print the array and the greatest value
for ( int i=0; i < MAX_A; i++) {
for (int j=0; j < MAX_B; j++){
cout << numberArray[i] [j] << "";
}
cout << endl;
}
system("PAUSE");
int highest = 0;
for ( int i=0; i< MAX_A; i++){
for (int j=0; j < MAX_B; j++){

// print the item
if (highest < numberArray[i][j])
highest = numberArray[i][j];
// print highest
cout << "Highest:" << highest << endl;
}
}

}



it doesn't print the array values or the highest number... how can i get it to display?

how do i find the location of the elements inputted and display them?
Is there any special reason why you use a two dimensional array? It only over-complicates the problem...
my prof wants me to use a two dimensional array. if it was one i would have no problem doing so.

do u have any ideas?
Topic archived. No new replies allowed.