输入一个正整数repeat (0 输入一个整数,从高位开始逐位输出它的各位数字。
输出语句:printf("%-2d", digit);
例:括号内是说明
输入
3 (repeat=3)
123456
-600
8
输出
1 2 3 4 5 6
6 0 0
8
#include <stdio.h>
int main( )
{
int ri, repeat;
int digit;
long in, temp, pow;
scanf("%d", &repeat);
for(ri=1; ri<=repeat; ri++){
scanf("%ld", &in);
if(in<0)
in=-in;
temp=in;
pow=1;
while(temp!=0){
temp=temp/10;
pow=pow*10;
}
pow=pow/10;
while(pow!=0){
digit=in/pow;
printf("%-2d", digit);
in=in%pow;
pow=pow/10;
}
printf("\n");
}
}
输出语句:printf("%-2d", digit);
例:括号内是说明
输入
3 (repeat=3)
123456
-600
8
输出
1 2 3 4 5 6
6 0 0
8
#include <stdio.h>
int main( )
{
int ri, repeat;
int digit;
long in, temp, pow;
scanf("%d", &repeat);
for(ri=1; ri<=repeat; ri++){
scanf("%ld", &in);
if(in<0)
in=-in;
temp=in;
pow=1;
while(temp!=0){
temp=temp/10;
pow=pow*10;
}
pow=pow/10;
while(pow!=0){
digit=in/pow;
printf("%-2d", digit);
in=in%pow;
pow=pow/10;
}
printf("\n");
}
}
Add a comment



输出素数(使用函数)
我们的纪念







