Anonymous user
Multiplication tables: Difference between revisions
→{{header|C++}}
m (→{{header|Python}}: Another way to convert to 2.X) |
|||
Line 100:
<lang cpp>#include <iostream>
#include <iomanip>
#include <cmath> // for log10()
#include <algorithm> // for max()
size_t get_table_column_width(const int min, const int max)
{
unsigned int abs_max =
// abs_max is the largest absolute value we might see.
Line 116 ⟶ 111:
// of the largest possible absolute value.
// Add one for a little whitespace guarantee.
size_t colwidth =
bool has_negative_result = false;▼
// If
▲ // be negative.
// If some values may be negative, then we need to add some space
// for a sign indicator (-)
if(has_negative_result)
colwidth
return colwidth;
|