As part of a larger assignment I am working on, I am trying to find a way to find rows and columns of a two dimensional array from input alone.
Currently what I am doing to set parameters is just asking for rows and columns. (see below/disregard some of the directives, initializes).
But what I'd like to do like be able to do is just skip the part where I am setting rows and columns by way of input; and instead be able to just input the values of the array in a sort of matrix way and obtain rows and columns that way. Is this possible?
//what I'd to be able to do
Enter values:
1 2 3 4
5 6 7 8
//the array would then be ex_array[2][4]
//current method I am using
#include<iostream>
#include<cmath>
#include <iomanip>
using namespace std;
int main()
{
int n,m;
double sqt;
double elevation;
double answer;
int array[10][10];
int lowest,highest;
int lowest_x_coordinate_index;
int lowest_y_coordinate_index;
int highest_x_coordinate_index;
int highest_y_coordinate_index;
cout<<"Enter No of rows: ";
cin>>m;
cout<<"Enter No of columns: ";
cin>>n;
cout<<"Enter values:\n";
//Read array values from keyboard
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cin>>array[i][j];
}
}
}