博客
关于我
判断数据的现象(递增、减小、稳定、无序)
阅读量:690 次
发布时间:2019-03-17

本文共 682 字,大约阅读时间需要 2 分钟。

在嵌入式行业很多数据需要知道是增大、减小、稳定还是无序,下面程序就是数据现象:

/***********2:稳定、1:递增、0:无序、-1:递减*******/#include
#define LIGHT_DATA_COUNT_MAX 7typedef enum{ LIGHT_DATA_DECREASE=-1, LIGHT_DATA_DISORDER=0, LIGHT_DATA_INCREASE, LIGHT_DATA_STABLE, LIGHT_DATA_MAX} LIGHT_DATA_ENUM;static int ordered(int *pdat, int len){ int t = 0,order = 0; if(len == 1) return 2; t = (pdat[0]
pdat[1])+2*(pdat[0]==pdat[1]); order = ordered(pdat + 1,len - 1); if(t*order == 0 || t*order == -1) return 0; if(t > order) t = order; return t;}int main (void){ int glare_data[LIGHT_DATA_COUNT_MAX] = {30,26,19,19,17,15,13}; int t = ordered(glare_data,LIGHT_DATA_COUNT_MAX); printf("t = %d\n",t); return 0;}

 

转载地址:http://sljhz.baihongyu.com/

你可能感兴趣的文章
Nginx + Tomcat + SpringBoot 部署项目
查看>>
Nginx + uWSGI + Flask + Vhost
查看>>
Nginx - Header详解
查看>>
nginx - thinkphp 如何实现url的rewrite
查看>>
Nginx - 反向代理、负载均衡、动静分离、底层原理(案例实战分析)
查看>>
Nginx - 反向代理与负载均衡
查看>>
nginx 1.24.0 安装nginx最新稳定版
查看>>
nginx 301 永久重定向
查看>>
nginx 301跳转
查看>>
nginx 403 forbidden
查看>>
nginx connect 模块安装以及配置
查看>>
nginx css,js合并插件,淘宝nginx合并js,css插件
查看>>
Nginx gateway集群和动态网关
查看>>
nginx http配置说明,逐渐完善。
查看>>
Nginx keepalived一主一从高可用,手把手带你一步一步配置!
查看>>
Nginx Location配置总结
查看>>
Nginx log文件写入失败?log文件权限设置问题
查看>>
Nginx Lua install
查看>>
nginx net::ERR_ABORTED 403 (Forbidden)
查看>>
vue中处理过内存泄露处理方法
查看>>