+ 3
To count number of digits
Input : 789 Output : 3
1 Réponse
+ 4
#include <iostream>
using namespace std;
int main()
{
int x;
int count=0;
int d=10;
cin>> x;
do
{
if(x/d!=0)
{
count++;
d*=10;
}
else
{
d=0;
}
}while(d!=0);
cout << count+1 << endl;
return 0;
}