AcWing 752. 数组的右方区域
原题链接
中等
作者:
王小强
,
2021-03-20 18:09:54
,
所有人可见
,
阅读 358
找规律
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv) {
char op;
float g[12][12];
scanf("%c", &op);
for (int y = 0; y < 12; ++y)
for (int x = 0; x < 12; ++x) scanf("%f", *(g + y) + x);
int cnt = 0;
float sum = 0.0;
for (int y = 1; y <= 5; ++y)
for (int x = 12 - y; x < 12; ++x)
++cnt, sum += *(*(g + y) + x);
for (int y = 6; y <= 10; ++y)
for (int x = y + 1; x < 12; ++x)
++cnt, sum += *(*(g + y) + x);
if (op == 'S') printf("%.1f\n", sum);
else printf("%.1f\n", sum / cnt);
return 0;
}