我有一个一维数组和一个二维数组。我将它们都放在我用来从 .txt 文件中读取信息的函数中。
据我所知,我的数组和函数都已正确设置,但我只是不知道如何实际调用其中包含 2 个独立数组的函数。这是相关信息,请告诉我我需要在main中输入什么来调用函数。谢谢!
void getSales(double[][QUARTERS], int[]); // places sales figures into the array
void printSales(double[][QUARTERS], int[]); // prints data as a table
void printTableHeading(); // prints table heading
int main()
{
double sales[YEAR_COUNT][QUARTERS]; // 2D array to hold the sales transactions
int years[YEAR_COUNT]; // 1D array to hold the years
return 0;
}
void printTableHeading()
{
}
void getSales(double salesTable[][QUARTERS],int yearArray[])
{
}
void printSales(double salesTable[][QUARTERS], int yearArray[])
{
}
最佳答案
int main(
{
getSales(sales, years); // Will call your get sales function
printSales(sales, years); // Will call your print sales function
}
关于c++ - 一维与二维数组相结合。需要在 main 中调用的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16159577/