#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int i,j=1;
cin>>i;
if(i<0)
i=fabs(i);
else
{
for(;i/10!=0;i=i/10)
j++;
}
cout<<"j="<<j<<endl;
return 0;
}
时间: 2024-10-13 16:36:07
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int i,j=1;
cin>>i;
if(i<0)
i=fabs(i);
else
{
for(;i/10!=0;i=i/10)
j++;
}
cout<<"j="<<j<<endl;
return 0;
}