AcWing 751. 数组的左方区域
原题链接
简单
作者:
flusca
,
2024-10-01 20:56:58
,
所有人可见
,
阅读 2
#include <cstdio>
int main()
{
char t;
scanf("%c", &t);
double a[12][12];
for (int i = 0; i < 12; i++)
{
for (int j = 0; j < 12; j++) scanf("%lf", &a[i][j]);
}
int c = 0;
double sum = 0;
for (int i = 1; i <= 5; i++)
{
for (int j = 0; j <= i - 1; j++)
{
sum += a[i][j];
c += 1;
}
}
for (int i = 6; i < 11; i++)
{
for (int j = 0; j <= 10 - i; j++)
{
sum += a[i][j];
c += 1;
}
}
if (t == 'S') printf("%.1lf", sum);
else printf("%.1lf", sum / c);
return 0;
}