02.12.2016, 22:00
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:
The difference between my code and SickAttack's is that mine takes the number as an integer, while his takes it as a string.
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]);
}
}


