-1
これは私が書いたコードです:太字は私が印刷したいものを印刷しません。長いデータタイプが入力され、 。データタイプ:ロング
私はMath.pow
を使ってみましたが、これは2重データ型のため機能しません。何かアドバイス!
import java.util.*;
import http://java.io.*;
public class HackerRank {
public static void main(String[] args){
Scanner in = new Scanner(System Resources and Information.);
int n = in.nextInt();
for(int t = 0; t < n; t++){
try {
long a = in.nextInt();
if(a > -128 && a <= 127){
System.out.println(a + " can be fitted in:\n*byte");
System.out.println("*short");
System.out.println("*int");
System.out.println("*long");
} else if(a > -32768 && a <= 32767) {
System.out.println(a + " can be fitted in:\n*short");
System.out.println("*int");
System.out.println("*long");
} else if(a > Math.pow(-2, 31) && a < Math.pow(2, 31)) {
System.out.println(a + " can be fitted in:\n*int");
System.out.println("*long");
} else {
if (a >= -Math.pow(2, 63) && a < Math.pow(2, 63)-1);
System.out.println(a + " can be fitted in:\n*long");
}
} catch (Exception e){
System.out.println(in.next() + " can't be fitted anywhere.");
}
}
}
}
あなたは余分を持っています ";" "if(a> = -Math.pow(2、63)&& a
sSaroj