文章目录
- AcWing 752. 数组的右方区域
- AC代码
AcWing 752. 数组的右方区域
本题链接:AcWing 752. 数组的右方区域
本博客给出本题截图:
AC代码
代码:
#include <cstdio> #include <iostream> using namespace std; int main() { char t; cin >> t; double q[12][12]; for (int i = 0; i < 12; i ++ ) for (int j = 0; j < 12; j ++ ) cin >> q[i][j]; double s = 0, c = 0; for (int i = 1; i <= 5; i ++ ) for (int j = 12 - i; j <= 11; j ++ ) { s += q[i][j]; c += 1; } for (int i = 6; i <= 10; i ++ ) for (int j = i + 1; j <= 11; j ++ ) { s += q[i][j]; c += 1; } if (t == 'S') printf("%.1lf\n", s); else printf("%.1lf\n", s / c); return 0; }