import java.util.*;
class rev_sum {
public static void main(String args[]) {
int a, i, n, m = 0, t = 0;
char c;
String w, p = " ";
Integer intCost = 0;
try {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number");
n = sc.nextInt();
w = Integer.toString(n);
a = w.length();
for (i = 0; i < a; i++) {
c = w.charAt(i);
p = c + p;
}
intCost = Integer.parseInt(p);
m = n + intCost;
System.out.println("The sum of the original no and reversed number =" + m);
} catch (NumberFormatException ex) {
}
}
}
這表明數字格式異常請幫助我需要數不將字符串轉換爲整型
這是不可讀的。 –
你的問題是什麼? –
你的空間有問題:** p =「」**將其改爲** p =「」** –