递归法判断一个数组为递增
2015-09-20 10:08
295 查看
题目:递归法判断一个数组为递增数组。
算法如下:
递归一般用到 if 判断语句。
/*点滴积累*/
算法如下:
#include <iostream> using namespace std; bool is_increease_array(int a[],int n) { if(n == 1) return false; if(n == 2) return a[n-1] > a[n-2]; return is_increease_array(a,n-1) && (a[n-1] > a[n-2]); } int main() { int a[] = {1,2,3,2,5,6}; if(is_increease_array(a,6)) cout << "increase" << endl; else cout << "NO" << endl; return 0; }
递归一般用到 if 判断语句。
/*点滴积累*/
相关文章推荐
- listview分页加载的实现
- spring技术内幕之spring aop的实现
- J-Link GDB Server Command
- C++中类的构造函数调用顺序
- centos5.x编译安装apache 手记
- 放空自己
- POJ 2456 Aggressive cows(二分)
- 关于Objective-C的内存管理图解
- 问题总结
- tarjan算法
- 每天至少保证4个小时的学习时间
- 网页制作中的技巧
- Java实现的各种排序算法
- html页面中meta的作用
- Navicat for MySQL 11.0.10 +破解补丁
- 用srs-librtmp写了一个rtmp push程序,将IPC的video data push到srs上。
- hdu 5464 Clarke and problem
- git学习,什么是git?
- sysbench相关
- 加密解密、openssl、私有CA创建过程