当前位置:网站首页>【码蹄集新手村 600 题】计算一个整数有多少位数
【码蹄集新手村 600 题】计算一个整数有多少位数
2022-07-17 18:23:00 【Sandm *】
题目如下:

解题思路:
利用 while 循环与运算符 / 去解决
注意点:
要对数据分俩种情况讨论,
如果不加以判断
当测试的数据为数字 0 时,所给出的位数为 0 ,而不是 1
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main( )
{
int data = 0;
cin >> data;
int count = 0;
if(data == 0)
{
count++;
}
else
{
while(data)//当所给数字为0时程序所给出的位数为0,而不是1
{
data = data / 10;
count++;
}
}
cout << count;
return 0;
}边栏推荐
- Module 7 (Architecture Design of King glory mall)
- LeetCode 0117. 填充每个节点的下一个右侧节点指针 II
- [record of question brushing] 13 Roman numeral to integer
- Unveiling secrets of matrixcube 101 - functions and architecture of matrixcube
- 基于PMOS的过压保护(OVP)电路仿真
- onvif协议相关:2.1.3 none方式获取流地址
- 弘业期货网上开户安全吗?有没有开户指引?
- 基于MOS管的防反接电路设计仿真
- [Yugong series] July 2022 go teaching course 012 forced type conversion
- onvif协议相关:4.1.1 WS-Username token方式获取WSUsernameTokenBean
猜你喜欢

Wrong again, byte alignment and the use of pragma pack

C语言进阶——自定义类型:结构体 枚举 联合

565. Array nesting

Advanced C language -- character function and string function

565.数组嵌套

ONVIF Protocol Related: 4.1.3 WS - username token Method get capture d'écran URL

Fluorine modified uio-66 | 3,4-dihydroxybenzaldehyde modified uio-66-nh2 | camptothecin derivative / oligopeptide @zif-8 nano drug carrier system

How to upgrade Flink job gracefully?

Module 7 (Architecture Design of King glory mall)

VMware导入ova/ovf虚拟机文件
随机推荐
S32K148_CAN驱动(裸机开发)
Responsive Zhimeng template logistics and freight service website
Nitrogen heterocyclic molecule modified uio-66-nh2 | polyethyleneimine modified uio-66-nh2| [email protected] @Zif67 nanomaterial
onvif协议相关:3.1.2 Digest方式获取token列表
动手学深度学习(第二版)注释后代码【持续更新】
MOF customized material | NH (2) -uio66/rgo Graphene Oxide Nanocomposite | methylene blue loaded zif-90 nanoparticles
CMOS switch learning (I)
基于PMOS的过压保护(OVP)电路仿真
Array simulation queue
Uio-66 | fe3o4/cu3 (BTC) 2 metal organic framework (MOF) nanocomposites supported on silver nanoparticles | nagdf4:yb, er upconversion nanoparticles @zif-8
模板虚拟机环境准备
名片管理的框架搭建
Ossimport migration path
如何优雅的升级 Flink Job?
【南瓜书ML】(task2)线性模型的数学推导(最小二乘估计、广义瑞利商、极大似然估计等)
Chitosan coated pcn224 nanoparticles | metal organic skeleton fe-mil-88nh2 | nickel based MOF material (Ni MOF / NF)
ONVIF Protocol Related: 4.1.3 WS - username token Method get capture d'écran URL
Supported metal organic framework zif-8 / graphene oxide hydrogen storage material | titanium dioxide /zif-8 composite | silicon dioxide @zif8 nano material
codeforce:A. Difference Operations【数学思维】
ssh无密钥登录