用for循环怎么做
public class HelloWorld{
public static void main(String[] args){
int num = 999;
if (num >= 0 && num<=999999999){
for(int count = 0;num != 0; count++){
num/=10;
}
System.out.println("它是个"+ count+"位的数!");
} else{
System.out.println("输入有误!");
}
}
}
#include<iostream>
using namespace std;
int main()
{
int num;
cin >> num ;
int S1 = 1, S2 = 10;
for(int i = 1; i <= 10; i++)
{
if(num >= S1 && num <= S2)
{
cout << i << endl;
break;
}
else
{
S1 *= 10;
S2 *= 10;
}
}
return 0;
}
for(int i=0;i<10;i++)
{
if(num>0)
{
num/=10;
count++;
}
}
System.out.println("它是个"+count+"位的数!");