while (num !=0){
count++;
num=num/10;
}
System.out.print("它是个"+count+"位的数!");
count++;
num=num/10;
}
System.out.print("它是个"+count+"位的数!");
public class HelloWorld{
public static void main(String[] args) {
String myLove="我爱慕课网";
String _age="www.imooc.com";
System.out.println(myLove);
System.out.println(_age);
}
}
public static void main(String[] args) {
String myLove="我爱慕课网";
String _age="www.imooc.com";
System.out.println(myLove);
System.out.println(_age);
}
}
2022-03-18
感觉这道题不用嵌套语句啊,一个while就够啦,还是我没理解老师的意思啊
Scanner sc=new Scanner(System.in);
System.out.println("请输入一个10位以内的数字");
long num=sc.nextInt();
int count=0;
while (num>0){
count++;
num=num/10;
}
System.out.println(count+"位数");
Scanner sc=new Scanner(System.in);
System.out.println("请输入一个10位以内的数字");
long num=sc.nextInt();
int count=0;
while (num>0){
count++;
num=num/10;
}
System.out.println(count+"位数");
while循环也可以实现,比for 循环稍微简洁;
int i=0; //索引初始值
while (i<hobbys.length){
System.out.println(hobbys[i]);
i++;
}
int i=0; //索引初始值
while (i<hobbys.length){
System.out.println(hobbys[i]);
i++;
}
2022-03-12
show in explorer 这一行在新版本里面没有,本人用到是idea-2021版,右键找到 Open in,下拉菜单找到explorer也可以实现该功能
if(num<10){
count+=1;
System.out.println("它是个"+count+"位的数!");
}else{
count+=1;
while(10<=num){
num/=10;
count++;
}
System.out.println("它是个"+count+"位的数!");
}
count+=1;
System.out.println("它是个"+count+"位的数!");
}else{
count+=1;
while(10<=num){
num/=10;
count++;
}
System.out.println("它是个"+count+"位的数!");
}