View Code of Problem 54

#include<stdio.h>
#include<math.h>
int main(){
	int n;
	scanf("%d",&n);
	int i,j,k;
	int mask=1;
	int count=0;
	int t=n;
	while(t>9){
		t=t/10;
		count++	;
	}
	//printf("%d\n",count);
	for(i=0;i<count;i++){
		mask*=10;
	}
	while(mask>0){
		j=n/mask;
		n=n%mask;
		if(mask>9){
			printf("%d ",j);
		}else{
			printf("%d",j);
		}
		mask=mask/10;
		
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 54