题解 | #数字翻转#
数字翻转
https://www.nowcoder.com/practice/bc62febdd1034a73a62224affe8bddf2
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int x = in.nextInt(); int y = in.nextInt(); int ans = rev(rev(x) + rev(y)); System.out.println(ans); } public static int rev(int n){ String str = String.valueOf(n); char[] s = str.toCharArray(); reverse(s); String a = new String(s); int ans = Integer.valueOf(a); return ans; } public static void reverse(char[] s){ int len = s.length; for(int i = 0; i < len / 2 ; i ++ ){ char c = s[i]; s[i] = s[len - i - 1]; s[len - i - 1] = c; } } }#我的实习求职记录#