Fork me on GitHub

牛客网编程练习之网易2017校招题:数字翻转

image

 

这里为了方便,直接借助了StringBuilder实现翻转....

 

AC代码:

import java.util.Scanner;

/**
 * @author CC11001100
 */
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		System.out.println(reverse(reverse(sc.nextInt()) + reverse(sc.nextInt())));

	}

	private static int reverse(int n){
		return Integer.parseInt(new StringBuilder(Integer.toString(n)).reverse().toString());
	}

}

 

 

题目来源: https://www.nowcoder.com/practice/bc62febdd1034a73a62224affe8bddf2?tpId=85&tqId=29854&tPage=1&rp=1&ru=/ta/2017test&qru=/ta/2017test/question-ranking

.

posted @ 2017-12-10 18:27  CC11001100  阅读(195)  评论(0编辑  收藏  举报