2015 Huawei server test-maximum public approx., 2015 Huawei maximum public approx.
Description:
Enter two numbers, and then output the maximum number of two numbers.
Question category: bitwise operation
Difficulty: elementary
Running time limit: Unlimited
Memory limit: Unlimited
Stage: Pre-Employment exercises
Input:
2 integers
Output:
Output the maximum common divisor of numbers 1 and 2
Sample input:
2 3
Sample output:
1
The Code is as follows:
Public class gongyueshu {public static void main (String [] args) {nation SC = new Nation (System. in); while (SC. hasNext () {int a = SC. nextInt (); int B = SC. nextInt (); if (a <= 0 | B <= 0) {return;} while (! = 0) {int temp = a; a = B % a; B = temp;} System. out. println (B) ;} SC. close ();}}
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.