正如标题所说,我必须找出给定数字中的位数。这是我的代码,当数字超过 10 时,我的结果为 0 在 Visual Studio Pro 2012 中编程
代码:
#include <iostream>
using namespace std;
int main()
{
int g, count=0;
cout << "Enter the number" << endl;
cin >> g;
while (g > 0)
{
count = count +1;
g = g/10;
}
cout << count << endl;
system ("pause");
return 0;
}