0
我正在嘗試編寫UVa 594 "One Little, Two Little, Three Little Endians"的java代碼。UVa中的運行時錯誤594
長話短說:問題是關於從輸入流中獲取輸入並從小端到大端轉換,反之亦然。 這裏是我的代碼:
class Little_endians {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int x;
String str;
while((str=br.readLine())!=null){
x=Integer.parseInt(str);
System.out.println(x+" converts to "+Integer.reverseBytes(x));//converting to the other endian just requires to reverse the bytes
}
}
}
它的工作原理上給出的所有樣品輸入,但在提交它表明: 您提交的問題594 - 一小,二小,三個小Endians已經失敗,判決運行錯誤。這意味着程序的執行沒有正確完成。請記住始終用退出碼0終止您的代碼。
我認爲可能會拋出IOException處理退出代碼0.任何人都可以幫我找到運行時錯誤的原因。
使用'掃描儀'來規避換行符和其他意想不到的空白問題。 –
@NiklasB。謝謝。我會檢查掃描儀。你能告訴我上述代碼中的問題嗎? – piyukr
可能與空白有關 –