解题思路:
注意事项:
参考代码:
//写一函数,输入一个四位数字,要求输出这四个数字字符,但每两个数字间空格。如输入1990,应输出"1 9 9 0
#include<stdio.h>
int main()
{
void p(int , char x[]);
int n;
char a[100];
scanf("%d",&n);
p(n,a);
return 0;
}
void p(int s ,char x[])
{
int i=0,count=0;
while(s>0)
{
x[i++]=s%10;//从个位往前赋给数组
s/=10;
count++;//判断是几位数
}
for(i=count-1;i>=0;i--)//因为是从个位往前赋给数组,所以逆序输出
printf("%d ",x[i]);
}
0.0分
0 人评分