課程
/后端開發
/Java
/Java入門第一季(IDEA工具)升級版
編程聯系那個999? 一點頭緒沒有? 求解?
2016-10-21
源自:Java入門第一季(IDEA工具)升級版 4-15
正在回答
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
if (num >= 0 ?&& num<=999999999){
while(num != 0){
count++;
num/=10; ? ? ? ? ?//因為num是int類型 999/10=99 ? 不保存小數點后的數。
}
System.out.println("它是個"+ count+"位的數!");
} else{
System.out.println("輸入有誤!");
public class HelloWorld {
int num =999;
int count =0;
for(int i=11;i>=0;i--){
if(num/((int)java.lang.Math.pow(10, i))>0){
count=i+1;
break;
System.out.println(count);
謝謝你
望采納
舉報
0基礎萌新入門第一課,從Java環境搭建、工具使用、基礎語法開始
2 回答4-15的編程題
6 回答4-15 編程練習
2 回答編程練習4-15
5 回答編程練習4-15
3 回答4-15編程練習
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-10-21
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
if (num >= 0 ?&& num<=999999999){
while(num != 0){
count++;
num/=10; ? ? ? ? ?//因為num是int類型 999/10=99 ? 不保存小數點后的數。
}
System.out.println("它是個"+ count+"位的數!");
} else{
System.out.println("輸入有誤!");
}
2016-11-03
public class HelloWorld {
public static void main(String[] args){
int num =999;
int count =0;
for(int i=11;i>=0;i--){
if(num/((int)java.lang.Math.pow(10, i))>0){
count=i+1;
break;
}
}
System.out.println(count);
2016-10-21
謝謝你
2016-10-21
望采納