这个代码怎么写啊:输入一个五位数,分割该数各个位上的数,并\t分隔开来,请各位指教
在线等
2008-12-12 16:05
程序代码:只限定于5位,不能多,也不能少。
[code]#include<stdio.h>
int main(void)
{
long a;
int b=10000;
printf("input a:\n");
scanf("%ld",&a);
for(;b>0;a-=(int)(a/b)*b,b/=10)
printf("%ld\t",a/b);
printf("\n");
return 0;
}
[/code]
2008-12-12 16:17
2008-12-12 16:29
2008-12-12 16:59
2008-12-12 17:00
2008-12-12 17:27
程序代码:#include <stdio.h>
int main(void)
{
long a,b=1;
printf("please input a number");
scanf("%ld",&a);
while(b<a)
b*=10;
b/=10;
for(;b>0;a-=(int)(a/b)*b,b/=10)
printf("%ld\t", a/b);
printf("\n");
return 0;
}
2008-12-12 17:30
2008-12-12 17:50
2008-12-12 18:02
2008-12-12 18:03