kopia lustrzana https://gitlab.com/tomaszg/geostat
Get rid of unnecessary arrays in computation of matrices
rodzic
6c6b08ff27
commit
f23739062c
15
geostat.cpp
15
geostat.cpp
|
@ -327,7 +327,7 @@ int main(int argc, char** argv) {
|
|||
show_histogram(cc, &Cache::year, "Years", 1, 0);
|
||||
|
||||
// DT matrix
|
||||
short dt_table[11][11];
|
||||
short count;
|
||||
int n = 0;
|
||||
|
||||
std::cout << "<h2>Difficulty / terrain matrix</h2>\n";
|
||||
|
@ -341,11 +341,11 @@ int main(int argc, char** argv) {
|
|||
for (int i = 2; i <= 10; i++) { // i -> diff in rows
|
||||
std::cout << "<tr><td class=\"dt_head\">" << i / 2.0 << "</td> ";
|
||||
for (int j = 2; j <= 10; j++) { // j -> terr in cols
|
||||
dt_table[i][j] = std::count_if(cc.begin(), cc.end(), [i, j](Cache c) { return (c.diff == i / 2.0 && c.terr == j / 2.0); });
|
||||
if (dt_table[i][j] == 0)
|
||||
count = std::count_if(cc.begin(), cc.end(), [i, j](Cache c) { return (c.diff == i / 2.0 && c.terr == j / 2.0); });
|
||||
if (count == 0)
|
||||
std::cout << "<td class=\"dt_zero\">" << 0 << "</td>";
|
||||
else {
|
||||
std::cout << "<td>" << dt_table[i][j] << "</td>";
|
||||
std::cout << "<td>" << count << "</td>";
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
@ -358,7 +358,6 @@ int main(int argc, char** argv) {
|
|||
std::cout << "</div>\n";
|
||||
|
||||
// Days matrix
|
||||
short days_table[12][31];
|
||||
n = 0;
|
||||
|
||||
std::cout << "<h2>Caching days matrix</h2>\n";
|
||||
|
@ -372,11 +371,11 @@ int main(int argc, char** argv) {
|
|||
for (int i = 1; i <= 12; i++) { // i -> months in rows
|
||||
std::cout << "<tr><td class=\"dt_head\">" << i << "</td> ";
|
||||
for (int j = 1; j <= 31; j++) { // j -> days in cols
|
||||
days_table[i-1][j-1] = std::count_if(cc.begin(), cc.end(), [i, j](Cache c) { return (c.date_tm.tm_mon == i && c.date_tm.tm_mday == j); });
|
||||
if (days_table[i-1][j-1] == 0)
|
||||
count = std::count_if(cc.begin(), cc.end(), [i, j](Cache c) { return (c.date_tm.tm_mon == i && c.date_tm.tm_mday == j); });
|
||||
if (count == 0)
|
||||
std::cout << "<td class=\"dt_zero\">" << 0 << "</td>";
|
||||
else {
|
||||
std::cout << "<td>" << days_table[i-1][j-1] << "</td>";
|
||||
std::cout << "<td>" << count << "</td>";
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue