博客
关于我
判断数据的现象(递增、减小、稳定、无序)
阅读量: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/

你可能感兴趣的文章
NFS的常用挂载参数
查看>>
NFS网络文件系统
查看>>
NFS远程目录挂载
查看>>
nft文件传输_利用remoting实现文件传输-.NET教程,远程及网络应用
查看>>
NFV商用可行新华三vBRAS方案实践验证
查看>>
ng build --aot --prod生成文件报错
查看>>
ng 指令的自定义、使用
查看>>
ng6.1 新特性:滚回到之前的位置
查看>>
nghttp3使用指南
查看>>
Nginx
查看>>
nginx + etcd 动态负载均衡实践(一)—— 组件介绍
查看>>
nginx + etcd 动态负载均衡实践(三)—— 基于nginx-upsync-module实现
查看>>
nginx + etcd 动态负载均衡实践(二)—— 组件安装
查看>>
nginx + etcd 动态负载均衡实践(四)—— 基于confd实现
查看>>
Nginx + Spring Boot 实现负载均衡
查看>>
Nginx + Tomcat + SpringBoot 部署项目
查看>>
Nginx + uWSGI + Flask + Vhost
查看>>
Nginx - Header详解
查看>>
nginx - thinkphp 如何实现url的rewrite
查看>>
Nginx - 反向代理、负载均衡、动静分离、底层原理(案例实战分析)
查看>>