现在的位置: 首页 > 综合 > 正文

求一个整数的位数–除法运算符的应用

2013年03月25日 ⁄ 综合 ⁄ 共 280字 ⁄ 字号 评论关闭

// GetNumberCount.cpp : 定义控制台应用程序的入口点。
//此算法获取一个整数的个数

#include "stdafx.h"
#include <process.h>
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{

cout<<"情输入一个整数:";
int n;
cin>>n;
int count=0;
while (n!=0)
{
n=n/10;
count++;
}
cout<<"这个数是"<<count<<"位数"<<endl;
system("pause");
return 0;

}




抱歉!评论已关闭.