Datahub
数据改变生活

3246: 【I级】【模拟】数字识别

发表时间:2022-10-27 20:00

3246: 【I级】【模拟】数字识别

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

题目描述

输入一个不多于四位的正整数,求出它是几位数,并分别打印出各位上的数字。

输入

输入一个不多于四位的正整数x(1<=x<=9999)。

输出

第一行输出x的位数num,接下来num行从高位到低位输出x的每一位上的数字。

样例输入 Copy

123

样例输出 Copy

3

1

2

3

#include<bits/stdc++.h>

using namespace std;

int main(){

int x;

cin>>x;

if(x>=1000){

cout<<4<<endl;

printf("%d\n%d\n%d\n%d\n",x/1000,x/100%10,x/10%10,x%10);

}

else if(x>=100){

printf("3\n");

cout<<x/100<<endl<<x/10%10<<endl<<x%10<<endl;

}

else if(x>=10){

cout<<2<<endl;

printf("%d\n%d\n",x/10,x%10);

}

else cout<<1<<endl<<x<<endl;

return 0;

}


QQ:258506508                                     联系电话:020-000000    000-000000                                   联系邮箱:xxx@.co.m                                     联系地址:XXX省XXX市XXX县XXX路