From 4b75f787ea70140462f59fc36248f50f61c4a889 Mon Sep 17 00:00:00 2001 From: nihonium Date: Mon, 14 Feb 2022 21:17:35 +0300 Subject: [PATCH] removed magic numbers --- numbers/sum.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numbers/sum.c b/numbers/sum.c index c6199ab..1f4ebff 100644 --- a/numbers/sum.c +++ b/numbers/sum.c @@ -24,11 +24,11 @@ int main(int argc, char *argv[]) { int len = strlen(z); int res = 0; for (int i = len-1; i >= 0; --i) { - if (z[i]>=48 && z[i]<=57) { + if (z[i]>='0' && z[i]<='9') { res += (z[i] - '0') * pow_(27, len-i-1); } else { - res += (z[i] - 54) * pow_(27, len-i-1); + res += (z[i] - 'A' + 10) * pow_(27, len-i-1); } } printf("%.3f\n", x+y+res);