第11周项目2-求最大公约数(1)
来源:互联网 发布:js让input不可编辑 编辑:程序博客网 时间:2024/05/17 17:40
问题及代码:
/* *Copyright(c)2014,烟台大学计算机学院 *Allrights reserved. *文件名称:MADE37.cpp *作 者:孙化龙 *完成日期:2014年11月6日 *版 本 号:v1.0 * *问题描述:输入两个数,并求出其最大公约数 *输入描述:两个数 *输出描述:其最大公约数*/#include <iostream>using namespace std;//自定义函数的原型(即函数声明)int gcd(int x,int y);int main(){ int a,b,g; cin>>a>>b; g=gcd(a,b); cout<<g<<endl; return 0;}int gcd(int x,int y){ int a,max; if(x<y) { max=y; y=x; x=max; } while(y!=0) { a=x%y; x=y; y=a; } return x;}
运行结果:
0 0
- 第11周项目2-求最大公约数(1)
- 第11周项目2-求最大公约数(1)
- 第11周项目2:求最大公约数
- 第11周项目2求最大公约数
- 第11周项目2-求最大公约数
- 第11周项目2-求最大公约数
- 第11周项目2-求最大公约数
- 第11周项目2-求最大公约数
- 第11周项目2-求最大公约数
- 第11周项目2-求最大公约数
- 第11周项目2:求最大公约数
- 第11周项目2 求最大公约数1
- 第11周项目2-求最大公约数(2)
- 第11周项目2-求最大公约数(2)
- 第11周项目2求最大公约数(2)
- 第11周项目2-求最大公约数(2)
- 第11周 项目2-求最大公约数(3)
- 第4周-项目1-求最大公约数(2)
- 计算机图形学的学习资源
- 叶贵丰谈下心情,谈下编程,谈下生活
- “大数据”时代,什么是数据分析做不了的?
- Problem 004——UVa 340 - Master-Mind Hints
- 区间DP 整数划分
- 第11周项目2-求最大公约数(1)
- 剑法三套,程序员也能挣大钱(一)
- JS基础——伸缩菜单2
- 屏蔽<a>标签的href跳转功能
- C++宏定义
- Jasper Report 教程
- 基于任务队列的多线程
- 小波变换简介(1)
- Problem 005——UVa 1583 - Digit Generator