파일에서 2 차원 배열, 행렬로 고도 값을 읽는 프로그램에서이 배열을 찾은 다른 함수에 전달하려고합니다. 최대치 기본적으로 배열은 참조로 전달된다는 것을 이해합니다. 그러나 함수의 배열 값을 변경하려고하지는 않으므로이 점이 중요하지 않습니다. 배열 호출에 대한 여러 페이지를 읽었지만 코드를 컴파일 할 때 발생하는 오류 유형에 대한 언급을 찾을 수 없었습니다. 문제는 호출되는 인수 또는 호출되는 방식에있는 것 같지만 함수의 다양한 모양에서 불일치를 볼 수 없습니다. 내 추측으로는 클래스에서 말하지 않은 2 차원 배열을 전달하는 것에 대해 뭔가있는 것 같아요. 아직 배웠던 것은 아닙니다. 어떤 도움이라도 대단히 감사하겠습니다. 코드는 다음과 같습니다2 차원 배열을 double 함수로 전달할 때 오류가 발생했습니다.
이오류 : 두 배 (*) (((긴 부호없는 int)를 (((긴 '변환 할 수 없습니다
#include <fstream>
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
// First instance of function declaration
double find_max(double elevations[][3600], double ilat, double ilon, int nlat, int nlon);
int main(int argc, char *argv[]) {
// Declare program variables
double lat_init, lon_init;
double lat_res, lon_res;
double peak, valley;
int lon_col, lat_row;
string indat, inpoints;
.
.
.
double elevations[lat_row][lon_col];
// Open and read topographic data file
ifstream topo_points;
topo_points.open(inpoints.c_str());
for (int i=0; i<lat_row; i++) {
for (int j=0; j<lon_col; j++)
topo_points >> elevations[i][j];
}
// Call function to find peak in the data
peak = find_max(elevations, lat_init, lon_init, lat_row, lon_col);
return 0;
}
// ***** Here lie the functions *****
// This function reads in the array of elevations, initial latitude and longitude
// of the data, and the number of data points and uses this information to find
// the latidude and longitude of the highest point on earth
double find_max(double elev[][3600], double ilat, double ilon, int nlat, int nlon) {
double num, max;
double latpos, lonpos;
max = 0;
for (int i=0; i<nlat; i++) {
for (int j=0; j<nlon; j++) {
num = elev[i][j];
if (num > max) {
max=num;
latpos= ilat - i;
lonpos= ilon + j;
}
}
}
cout << "The tallest peak on earth has an altitude of " << max;
cout << " and is located at " << latpos << "deg latitude and ";
cout << lonpos << "deg longitude";
return max;
}
그러나, 나는 다음과 같은 오류가 함수를 호출 할 때 find_max (double (*) [3600], double, double, int, int) '에 인수'1 '에 대해 double (*) [3600]
lon_col = 3600? – tmpearce