Description
输入一个正整数 repeat (0<repeat<10),做repeat 次下列运算:
输入一个整数,从高位开始逐位输出它的各位数字。
Input
输入的整数可能大于1030
Output
见sample
Sample Input
3
123456
-600
8
Sample Output
1 2 3 4 5 6
6 0 0
8
#include<stdio.h>
#include<string.h>
int main(){
int repeat,i;
char a[10000];
unsigned long x;
scanf("%d",&repeat);
getchar();
while(repeat--){
gets(a);
x=strlen(a);
if(a[0]=='-'){
for(i=1;i<x;i++){
if(i==1){printf("%c",a[i]);
}else{
printf(" %c",a[i]);
}
}
}else{
for(i=0;i<x;i++){
if(i==0){
printf("%c",a[i]);
}else{
printf(" %c",a[i]);
}
}
}
printf("\n");
}
return 0;
**⚠️输出数据末尾空格 就不能直接printf(" %c",a[i]); 或printf("%c ",a[i]);
if(i==1){printf("%c",a[i]);
}else{printf(" %c",a[i]);
}
用选择语句 第一位不加空格 后面的在输出前➕空格!