hailstone.cpp
来源:互联网 发布:js脚本入门 编辑:程序博客网 时间:2024/05/21 06:58
#include <iostream>using namespace std;int hailstone(int n){int length = 1;while (n > 1){n % 2 ? n = 3 * n + 1 : n /= 2;length++;}return length;}int main(){int n;cout << "Please input a integer: " << endl;cin >> n;int length;length = hailstone(n);cout << "The length of hailstone(" << n << ") is " << length << endl;}
0 0
- hailstone.cpp
- HAILSTONE
- Hailstone Sequence
- hailstone sequence
- Hailstone Sequence
- hdu 4484 Hailstone HOTPO
- Uva 6172 Hailstone HOTPO
- Mathematics-01 Hailstone Sequence
- hdu 4484 Hailstone HOTPO (暴力)
- UVALive 6172 Hailstone HOTPO (水
- HDU 4484 Hailstone HOTPO (记忆化搜索)
- HDU 4484 Hailstone HOTPO (简单模拟题)
- 3n+1问题(Hailstone问题)
- UVALive 6172|HDU 4484|Hailstone HOTPO|模拟
- cpp
- CPP
- CPP
- cpp
- 今天我住的这边发生一件大事了。
- Python基础教程(第四章)
- 使用Guava报错NoSuchMethodError的解决方法
- JAVA设置JTable表格的可编辑性
- PAT QQ帐户的申请与登陆(25)(map的应用)
- hailstone.cpp
- Python基础教程(第五章)
- Mybatis分页插件 - 示例
- java 序列化和反序列化总结
- Chrome中的onkeypress 的keyCode BUG
- ACboy needs your help(分组背包)
- PE文件结构(三) 输入表
- 数据结构 第一章绪论
- 百度bae的wp伪静态好难啊