1847 - 课后习题8.8
写一函数,输入一个四位数字,要求输出这四个数字字符,但每两个数字间空格。如输入1990,应输出"1 9 9 0"。
Input
一个四位数
Output
增加空格输出
Examples
Input
1990
Output
1 9 9 0
Solution 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); }
Solution 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; }