1847 - 课后习题8.8

通过次数

0

提交次数

0

时间限制 : 1 秒 内存限制 : 128 MB

写一函数,输入一个四位数字,要求输出这四个数字字符,但每两个数字间空格。如输入1990,应输出"1 9 9 0"。

题目输入

一个四位数

题目输出

增加空格输出

输入/输出样例

输入格式

1990

输出格式

1 9 9 0 

C语言解答

#include<stdio.h>
void fun(int m);
int main()
{
	int n;
	scanf("%d",&n);
	fun(n);
	return 0;
}
void fun(int m)
{
	printf("%c %c %c %c \n",(m/1000+48),(m/100%10+48),(m/10%10+48),m%10+48);
}

C++解答

#include<bits/stdc++.h>
using namespace std;
string x;
int main()
{
	cin>>x;
	for(int i=0;i<x.size();i++)
	    cout<<x[i]<<" ";
		
    return 0;
}