我有一个程序可以使用10x12矩阵计算销售公司的销售额。
销售公司在10个城市设有分支机构,该程序必须打印最近12个月每个分支机构的销售数量。然后打印当年的销售总数,最后就是打印销售的最小值和最大值
但是程序没有打印正确的最小值和最大值
这是代码
using namespace std;
int main() {
double F[10][12];
double sum[10] = { 0 };
double Msum[12] = { 0 };
int i = 0;
int j;
double x = 0;
double max = 0;
double Minimum = 100000000;
for (i = 0; i < 10; i++) {
cout << "please enter the " << i + 1 << " branch sale for the " << endl;
for (j = 0; j < 12; j++) {
cout << "month " << j + 1 << ": " << endl;
cin >> F[i][j];
}
}
for (i = 0; i < 10; i++)
for (j = 0; j < 12; j++)
sum[i] += F[i][j];
for (i = 0; i < 10; i++) {
cout << "the total sales for branch " << i + 1 << " is " << sum[i] << endl;
}
for (i = 0; i < 10; i++)
for (j = 0; j < 12; j++) {
x += F[i][j];
}
cout << "the total sales for all branches in the year is " << x << endl;
int min = INT_MAX;
int max = INT_MIN;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j <= 3 / 2; j++)
{
if (F[i][j] > F[i][3 - j - 1])
{
if (min > F[i][3 - j - 1])
min = F[i][3 - j - 1];
if (max < F[i][j])
max = F[i][j];
}
else
{
if (min > F[i][j])
min = F[i][j];
if (max < F[i][3 - j - 1])
max = F[i][3 - j - 1];
}
}
}
cout << "the branch that has the maximum sale in the year is " << max << endl;
cout << "the month that has the least sales in the year is " << min << endl;
return 0;
}```