Seeking greatest common divisor by the method of dividing

Source: Internet
Author: User
Tags greatest common divisor
Title Description:
Number of consecutive input n groups (2/group), the number of greatest common divisor per group
Input Description: The first line enters an integer n, followed by two integers per line x, y
Output Description: N rows, one number per line, greatest common divisor for x, y
Directly on the code--
1 #include <cstdio> 2  3 using namespace std; 4  5 int n,x,y; 6  7 int gcd (int a,int  {9
      
       int c=a%
       b;10 while (c!=0 {a a= b;13 b= c;14 c=a%}16  return }18 int {scanf ("% D ",&n); (int i=1;i<=n;i++ {scanf ("%d%d ",&x,&y); printf ("%d\n " }27 return 0}            
        

Seeking greatest common divisor by the method of dividing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.