6.3w+
社区成员
# include <iostream>
const int MONTHS=12;
const char *months[MONTHS]={"January","Febuary","March","April","May",
"June","July","August","September","October","November","December"};
int main()
{
using namespace std;
int j=0;
double sum=0.0;
int sales[3][MONTHS];
int month;
while(j <3)
{
cout <<"Enter the " <<j <<" year monthly sales for\"C++ for Fools\":\n";
for(month=0;month <MONTHS;month++) {
cout <<"Sales for " <<months[month] <<":";
cin>>sales[j][month];
}
double total=0.0;
for(month=0;month <MONTHS;month++)
total+=sales[j][month];
cout <<"Total sales:" <<total <<endl;
j++;
sum+=total;
}
cout <<"The 3 year's totol sales is:" <<sum <<endl;
return 0;
}