-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0059.cpp
More file actions
50 lines (38 loc) · 1.04 KB
/
0059.cpp
File metadata and controls
50 lines (38 loc) · 1.04 KB
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
45
46
47
#include <iostream>
#include <stdlib.h>
/*====================================
* eXcript.com
* fb.com/eXcript
* ====================================*/
using namespace std;
int main() {
//1) criar uma planilha com valores aleatórios
//2) soma dos valores de cada linha
//3) soma da soma dos valores de cada linha
double plan[5][6] = {};
// gerando a planilha
for(int x = 0; x < 5; x++){
for(int y = 0; y < 5; y++){
plan[x][y] = (double)rand() / RAND_MAX;
}
}
// calculo dos valores
double total = 0;
for(int x = 0; x < 5; x++){
for(int y = 0; y < 5; y++){
plan[x][5] += plan[x][y];
}
total += plan[x][5];
}
// imprimindo a planilha
// 0, 0, 0, 0, 0 = 0.0
for(int x = 0; x < 5; x++){
for(int y = 0; y < 6; y++){
string end = (y<4) ? ", " :
(y<5) ? " = " : "\n";
cout << plan[x][y] << end;
}
}
cout << "O valor da soma é: " << total << endl;
return 0;
}