当前位置:网站首页>Zzuli:1061 sequential output of digits
Zzuli:1061 sequential output of digits
2022-07-02 05:29:00 【Don't explode】
Title Description
Enter a value not greater than 10 Of 9 A positive integer to the power , Start from the high bit, divide it bit by bit and output each digit .
Input
Enter a positive integer n,n yes int Type data
Output
Output the numbers in turn , Each number is followed by a space , Output takes up one line . for example , Input 12345 , Output 1 2 3 4 5
The sample input Copy
12345
Sample output Copy
1 2 3 4 5
Tips
Pay attention to integer operation and avoid using double Functions of type, such as pow().
This problem can first use a cycle to calculate the highest bit weight h, And then a loop , The content of the loop is : Output highest bit (n/h)、 Throw away the top (n = n%h)、 Lower the highest position (h = h/10), Until the right position h by 0.
#include <stdio.h>
int main ()
{ int n,a,h;
scanf("%d",&n);
a=n;
h=1;
while(a>9)
{
a/=10;
h*=10;
}
while(h>0)
{
printf("%d ",n/h);
n%=h;
h/=10;
}
return 0;
}
边栏推荐
- Fabric.js IText 上标和下标
- Applet jumps to official account
- Collectors.groupingBy 排序
- Basic use of form
- Online music player app
- Ubuntu 20.04 installing mysql8
- Fabric. JS compact JSON
- Innovation never stops -- the innovation process of nvisual network visualization platform for Excel import
- Storage of data
- Black Horse Notes - - set Series Collection
猜你喜欢
Fabric. JS iText superscript and subscript
Fabric.js 激活输入框
数据的储存
Basic use of form
LeetCode 1175. Prime number arrangement (prime number judgment + Combinatorial Mathematics)
JVM class loading mechanism
【pyinstaller】_get_sysconfigdata_name() missing 1 required positional argument: ‘check_exists‘
Gee series: Unit 4 data import and export in Google Earth engine
在线音乐播放器app
Software testing learning - day 4
随机推荐
Gee series: unit 9 generate sampling data in GEE [random sampling]
Gee: find the spatial distribution and corresponding time of the "greenest" in the Yellow River Basin in 2020 [pixel by pixel analysis]
Fabric. JS iText sets the color and background color of the specified text
Online music player app
指针使用详解
黑馬筆記---Set系列集合
LS1046nfs挂载文件系统
简单封装 js并应用
Fabric. JS 3 APIs to set canvas width and height
Storage of data
Fabric. JS upload local image to canvas background
Visual studio import
运维工作的“本手、妙手、俗手”
A collection of commonly used plug-ins for idea development tools
Leetcode18题 【四数之和】递归解法
Importation de studio visuel
Pyechats 1.19 generate a web version of Baidu map
H5 jump applet
460. LFU cache bidirectional linked list
Résumé de la collection de plug - ins couramment utilisée dans les outils de développement idea