Damm algorithm: Difference between revisions
Content deleted Content added
Not a robot (talk | contribs) Add MACRO-11 |
m →{{header|C++}}: Shortened code a bit |
||
Line 760:
=={{header|C++}}==
{{trans|C#|C sharp}}
<syntaxhighlight lang="cpp">#include <
#include <cstdio>
const int TABLE[][10] = {▼
{0, 3, 1, 7, 5, 9, 8, 6, 4, 2},
{7, 0, 9, 2, 1, 5, 4, 8, 6, 3},
Line 775 ⟶ 777:
};
int interim = 0;
for (
interim = TABLE[interim][c - '0'];
}
Line 785 ⟶ 786:
int main() {
for (const auto
if (damm(std::to_string(num))) {
std::printf("%6d is valid\n", num);▼
} ▼
▲ printf("%6d is valid\n", num);
▲ printf("%6d is invalid\n", num);
▲ }
}
}</syntaxhighlight>
{{out}}
|