PAT(B) 1086 就不告诉你(Java)

题目链接:1086 就不告诉你 (15 point(s))

题目描述

做作业的时候,邻座的小盆友问你:“五乘以七等于多少?”你应该不失礼貌地围笑着告诉他:“五十三。”本题就要求你,对任何一对给定的正整数,倒着输出它们的乘积。

输入格式

输入在第一行给出两个不超过 1000 的正整数 A 和 B,其间以空格分隔。

输出格式

在一行中倒着输出 A 和 B 的乘积。

输入样例1

5 7

输出样例1

53

输入样例2

1000 1000

输出样例2

1

代码💻

/*********************************************************************************
Submit Time			Status		Score	Problem	Compiler		Run Time	User
7/19/2019, 20:23:00	Accepted	15		1086	Java (openjdk)	93 ms		wowpH
*********************************************************************************/
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
        int ans = A * B;
        while (0 == ans % 10) {							// 去掉末尾的零
            ans /= 10;
        }
		char[] arr = String.valueOf(ans).toCharArray();
		for (int i = arr.length - 1; i >= 0; --i) {		// 倒序输出
			System.out.print(arr[i]);
		}
	}
}
posted @ 2019-07-19 20:34  wowpH  阅读(287)  评论(0)    收藏  举报