03.12.2016, 00:21
Quote:
|
That code reminds me of the first year of C programming courses in highschool. I remember this was one of our homeworks.
Let me fix that for you: Code:
Repeat(number) {
new count[10];
if(number < 0)
number = -number; // this algorithm won't work properly on negative number since array indexes must be positive
while(number) {
new digit = number%10;
count[digit]++;
number /= 10;
}
for(new i = 0; i < 10; ++i) {
printf("Digit %d - %d times", i, count[i]);
}
}
|
Thanks for your code. It's clear. I don't know why I didnt' tough about this kind of version.
EDIT: I can't +rep because I already did it.


