/*
*Copyright (c) 2014, 烟台大学计算机学院
*All rights reserved.
*文件名称:week11-project2(2).cpp
*作者:管毓云
*完成日期:2014年 11 月 11 日
*版本号:v1.0
*
*问题描述:求两数的最大公约数
*输入描述:输入四个数
*程序输出:输出最大公约数
*/
#include <iostream>
using namespace std;
int gcd (int,int);
int gcds (int,int,int,int);
int main()
{
int a,b,c,d;
cin>>a >> b>>c>>d;
cout<<"最大公约数是:"<<gcds(a,b,c,d)<<endl;
return 0;
}
int gcd(int x,int y)
{
int z;
while (y!=0)
{
z=x%y;
x=y;
y=z;
}
return x;
}
int gcds(int x,int y,int z,int aw)
{
int n1,n2,n;
n1=gcd(x,y);
n2=gcd(z,w);
n=gcd(n1,n2);
return n;
}
学习方法与总结:每一个int后面都有一个空格。。。我。。。。。