Help me on a quest C ++

Oct 22, 2015 at 11:37am
Can you tell me if I error and where ??
Defining a two-dimensional array of real numbers double precision.

- How to find and index the minimum element of row K ... (help me please)


#include "stdafx.h"

using namespace System;

int main()
{
int i,j,a[0][5],n,m,min;
cout<<"3";
cin>>n;
cout<<"4";
cin>>m;
for(i=0;i<n;i++)
for(j=0;j<m;j++) {
cout<<"a["<<i<<"]["<<j<<"]=";
cin>>a[i][j];
}
for(i=0;i<n;i++) {
for(j=0;j<m;j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
cout <<"0"<<endl;
for(j=0;j<m;j++) {
min=a[0][j];
for(i=1;i<n;i++) {
if(a[i][j]<min)
min=a[i][j];
}
cout<<min<<" ";
}
return 0;
}
Oct 22, 2015 at 1:19pm
I'll assume you #include <iostream> in "stdafx.h". Other than that, you are trying to define a 2 d array with a 0 value...

int i,j,a[0][5],n,m,min;

You need a value greater than 0. Also, if you try to use 1 for the value, that's how a regular one-dimension array in c++ behaves, so it would just be better to use a one dimension array.

Also, you said you are creating a 2D array of "real numbers double precision". All of the values you have here are integers.

If you want double precision floating point numbers in this guessing game, you could design it that way, but your game would be insanely hard.
Last edited on Oct 22, 2015 at 1:24pm
Topic archived. No new replies allowed.