Last error Im getting is error C2059: syntax error : ']'
Anyone have any ideas?
what it needs to do:write a c++ program that creates using a random number generation a 2 dimentional array of integers whos values range from -9 to 9. The array size is to be chosen by the user of the program. Your program will then print the sum of the numbers that are in the same rowor column as the smallest entry. If the smallest entry occurs more then once you can pick which you want it to use (*I am just trying to use the first*) The main program is to use a function that returns the row and column position of the smallest entry. Allow for arrays up to 10x10 and the user to input the array info.
#include <iostream>
#include <ctime>
using namespace std;
void small(int [],int, int, int, int &,int &);
int main()
{
int r,c,q=0,h=0,w=0,array[10][10],sumr=0,sumc=0;
srand((unsigned)time(NULL));
cout << "Enter the hight of the array: ";
cin >> h;
cout << "Enter the width of the array: ";
cin >> w;
cout << endl;
for( r = 0 ; r < h ; r++ ){
for( c = 0 ; c < w ; c ++ ){
array[r][c] = rand()%19-9;
}
}
for( r = 0 ; r < h ; r++ ){
for( c = 0 ; c < w ; c ++ ){
cout << array[r][c] << ' ';
}
cout << endl;
}
small(*array[], &sumc, &sumr, r, h, w);
return 0;
}
void small(int *array[],int &sumc,int &sumr,int r,int h, int w)
{
int i = -9;
cout << "The row sum is: " << sumr;
for(int r = 0 ; r < h ; r++ )
{
for(int c = 0 ; c < w ; c ++ )
{
if(array[r][c]==i)
{
cout << "smallest row is: " << r << endl << "smallest column is: " << c;
for (int g = 0; g < 10; g++)
{
sumc = sumc + array[r][g];
sumr = sumr + array[g][c];
}
}
else
i--;
}
}
}