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