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
The Effective Engineer
Edmond Lau / The Effective Bookshelf, Palo Alto, CA. / 2015-3-19 / USD 39.00
Introducing The Effective Engineer — the only book designed specifically for today's software engineers, based on extensive interviews with engineering leaders at top tech companies, and packed with h......一起来看看 《The Effective Engineer》 这本书的介绍吧!