// C6_5.cpp : Defines the entry point for the console application. // 二維陣列與函數 -- 計算銷售總額 #include "stdafx.h" #include using namespace std; double Sale(double array[][4], int n); int main(int argc, char* argv[]) { // 宣告二維陣列 double Amount[3][4] = { { 780000, 920000, 630000, 1023000 }, { 752000, 760000, 880000, 890000 }, { 660000, 1090000, 840000, 990000 } }; cout << endl << "銷售額合計 = " << Sale(Amount, sizeof Amount/sizeof Amount[0]); cout << endl << "銷售額平均額 = " << Sale(Amount, sizeof Amount/sizeof Amount[0]) / 12; cout << endl; return 0; } // 函數計算總和 double Sale(double Amount[][4], int nn) { double total = 0.0; for(int i=0; i