AcWing 744. 数组中的列
原题链接
简单
作者:
wasd233
,
2024-03-05 18:41:32
,
所有人可见
,
阅读 23
C++
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
double M[12][12];
int c; cin >> c;
char x; cin >> x;
for (int i = 0; i < 12; i ++)
for (int j = 0; j < 12; j ++)
cin >> M[i][j];;
double s = 0;
for (int i = 0; i < 12; i ++)
s += M[i][c];
if (x == 'S') printf("%.1lf\n", s);
else printf("%.1lf\n", s / 12.0);
return 0;
}
Python
c = int(input())
x = input()
M = []
s = 0
for _ in range(12):
l = list(map(float, input().split()))
M.append(l)
for i in range(12):
s += M[i][c]
if x == 'S':
print(f"{s:.1f}")
else:
print(f"{s/12:.1f}")