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