C ++ review a maximum common appointment

Source: Internet
Author: User

/*
*ProgramCopyright and version declaration Section
* Copyright (c) 2011, a student from the computer College of Yantai University
* All Rights Reserved.
* File Name:
* Author: Zhang chuanxin
* Completion date: January 1, March 29, 2012
* Version No.: 1

* Description of tasks and Solutions
* Input description:
* Problem description: calculate the maximum common number.
* Program output:
* Problem Analysis :......
*AlgorithmDESIGN :......
*/

# Include <iostream> using namespace STD; int gcd (int x, int y); // calculate the maximum common approx. Void main () {int A, B, G; cout <"enter two positive integers:" <Endl; CIN> A> B; G = gcd (a, B); cout <"the maximum number of public approx. is: "<G <Endl ;}// calculate the maximum common approx. Int gcd (int x, int y) {If (x <Y) {int t; t = X; X = y; y = T;} while (y! = 0) {int R; r = x % Y; X = y; y = r;} return X ;}Running result:
 
 Computer comments: learn new things for a warm time!

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.