Assignment 8 Question 2
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int a[4];
int count =0;
a[0]=n%1000;
n=n/1000;
if(a[0]){
count=1;
}
a[1]=n%100;
n=n/100;
if(a[1]){
count=2;
}
a[2]=n%100;
n=n/100;
if(a[2]){
count=3;
}
a[3]=n%100;
n=n/100;
if(a[3]){
count=4;
}
int i;
for(i=0;i<count;i++)
{
printf("%d\n", a[i]);
}
return 0;
}
int main()
{
int n;
scanf("%d", &n);
int a[4];
int count =0;
a[0]=n%1000;
n=n/1000;
if(a[0]){
count=1;
}
a[1]=n%100;
n=n/100;
if(a[1]){
count=2;
}
a[2]=n%100;
n=n/100;
if(a[2]){
count=3;
}
a[3]=n%100;
n=n/100;
if(a[3]){
count=4;
}
int i;
for(i=0;i<count;i++)
{
printf("%d\n", a[i]);
}
return 0;
}
Comments
Post a Comment