int類型變量范圍超過了2147483648就錯誤,如果數值是10位以上用什么數據類型?
public class HelloWorld{
public static void main(String[] args){
int num = 2147483648 ;
int count = 0;
? ? if(num>=0 && num<=999999999){
? ? ? ? for(count=0;count<10;){
? ? ? ? ? count++;
? ? ? ? ? num/=10;
? ? ? ? ? if(num==0){
? ? ? ? ? ? ?break;
? ? ? ? ? ? }
? ? ? }
? ? ? System.out.println("它是個"+count+"位的數!");? }
? ? else{
? ? ? ? ? ?System.out.println("輸入有誤!");
? ? }
? ? ?
}
}
2019-05-22
用long 數值后面加小寫l
2019-07-15
?長整型