View Code of Problem 54

#include <stdio.h>
#include <math.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    long int n, t;
    int num[11], i = 0, s = 0;
    int k = 10, kk = 1;
    
    scanf("%ld", &n);
    t = n;
    
    while(t % k != n) {
        num[i++] = (t % k) / kk;
        k *= 10;
        kk *= 10;
        s++;
    }
    num[i] = (t % k) / kk;
    
    for(i = s; i > 0; i--) {
        printf("%d ", num[i]);
    }
    printf("%d\n", num[i]);
}

Double click to view unformatted code.


Back to problem 54