-
-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathabove_the_main_diagonal.cpp
More file actions
44 lines (31 loc) · 762 Bytes
/
Copy pathabove_the_main_diagonal.cpp
File metadata and controls
44 lines (31 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// https://www.urionlinejudge.com.br/judge/en/problems/view/1183
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;
int main() {
vector< vector<double> > v1;
double n, total=0;
string operation;
cin >> operation;
for (int i = 0; i < 12; i++) {
vector<double> v;
for (int j = 0; j < 12; j++) {
cin >> n;
v.push_back(n);
}
v1.push_back(v);
}
int counter = 1, count = 0;
for (int i = 0; i < 12; i++) {
for (int j = counter; j < 12; j++) {
total += v1[i][j];
count++;
}
counter++;
}
if (operation == "S") cout << fixed << setprecision(1) << total << endl;
else cout << fixed << setprecision(1) << total / count << endl;
return 0;
}