View Code of Problem 54

#include<stdio.h>
int main(){
	long int n;
	scanf("%ld",&n);
	int i, count = 0;
	long int t = n;
	while(t % 10 != 0 || t == 10){
		t /= 10;
		count ++;
	}
	
	while(1){
		long int s = 1;
		for(i = 0; i < count - 1 ; i ++){
			s = s * 10;
		}
		if(count == 1){
			printf("%d\n", n / s);
			break;
		} else {
			printf("%d ", n / s);
		}
		n = n % s;
		count --;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 54