/*
*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!