C 语言实例 - 判断数字为几位数

C 语言教程 · 2019-02-20 19:58:29

用户输入数字,判断该数字是几位数。

实例

#include <stdio.h> int main() { long long n; int count = 0; printf("输入一个整数: "); scanf("%lld", &n); while(n != 0) { // n = n/10 n /= 10; ++count; } printf("数字是 %d 位数。", count); }

运行结果:

输入一个整数: 2345
数字是 4 位数。

点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html

查看所有标签

Learning PHP, MySQL, JavaScript, and CSS

Learning PHP, MySQL, JavaScript, and CSS

Robin Nixon / O'Reilly Media / 2012-9-3 / USD 39.99

If you're familiar with HTML, you can quickly learn how to build interactive, data-driven websites with the powerful combination of PHP, MySQL, and JavaScript - the top technologies for creating moder......一起来看看 《Learning PHP, MySQL, JavaScript, and CSS》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

MD5 加密
MD5 加密

MD5 加密工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具