第11周项目--调用函数之求最大公约数
来源:互联网 发布:ubuntu改变文件所有者 编辑:程序博客网 时间:2024/05/28 23:22
<span style="color:#009900;">/* * Copyright (c) 2014, 烟台大学计算机学院 * All rights reserved. * 文件名称:test.cpp * 作 者:姜甜甜 * 完成日期:2014年 11 月 6 日 * 版 本 号:v1.0 * * 问题描述:输入两个数,并求出其最大公约数; * 输入描述: 两个数a、b; * 程序输出:a和b的最大公约数g;*/</span>#include <iostream>using namespace std;int gcd(int x,int y); <span style="color:#990000;"> //注意用分号;</span>int main(){ int a,b,g; cin>>a>>b; g=gcd(a,b); cout<<"最大公约数是:"<<g; return 0;}int gcd(int x,int y){ int z; while (y!=0) { z=x%y; x=y; y=z; } return x;}
小结:注意在主函数之前声明函数,注意算法。
0 0
- 第11周项目--调用函数之求最大公约数
- 第11周项目2用函数求最大公约数
- 第11周项目2:求最大公约数
- 第11周项目2求最大公约数
- 第11周项目 求最大公约数
- 第11周项目2-求最大公约数
- 第11周项目2-求最大公约数
- 第11周项目2-求最大公约数
- 第11周项目2-求最大公约数
- 第11周项目二 求最大公约数
- 第11周项目2.1求最大公约数
- 第11周项目2-求最大公约数
- 第11周项目2-求最大公约数
- 第11周项目2:求最大公约数
- 第12周项目3-递归函数求最大公约数
- 调用函数求最大公约数
- 第11周项目 求两个数的最大公约数
- 第11周项目1-求两个数的最大公约数
- warning LNK4070的解决办法
- springMVC @ResponseBody 返回结果乱码
- Logcat源码分析(一)
- 怎样正确的使用QThread类
- 第十一周---求两个数的最大公约数
- 第11周项目--调用函数之求最大公约数
- tableView加searchBar,以搜索通讯录为列
- kerberos 安装和配置
- 编程:函数版星号图 printchs函数
- 第11周项目一 函数版星号图(2)
- 第十一周 项目2:求最大公约数
- 第十周项目一。2
- photoshop 高手之路
- AssetBundle系列——游戏资源打包(二)