读取条空比例
2015-12-29 10:56
369 查看
对于一组01数据,计算它的宽度,以1为开头。
#include <iostream> using name space std; int main() { int message[] = { 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1}; int size = sizeof(message) / sizeof(int); int * countTransition = new int[size]; memset(countTransition, 0, sizeof(int)*size); int currentState = 0; for(int i = 0; i< size; i++) { if(message[i]) { if((currentState & 1) == 1) currentState ++; countTransition[currentState] ++; } else { if((currentState & 1) == 0) currentState ++; countTransition[currentState] ++; } } int num = currentState + 1; for(int i = 0; i < num; i++) { cout << countTransition[i] << endl; } delete[]countTransition; return 0; }
相关文章推荐
- MFC模态对话框
- lucene 评分公式 ——forfuture1978
- Object_C 回顾 0.0.1
- angularjs controller, service, directive 的demo
- Android ViewConfiguration.getScaledTouchSlop () 用法
- 猫猫学iOS之iOS键盘隐藏,下一个textField,键盘控制第三方好用框架IQKeyboardManager
- windows通过"运行"win+r实现快速打开应用程序
- javascript实现下拉提示选择框
- RK3288 UVC 摄像头调试
- 部分软件不能上网问题
- rsh,rlogin双机互信
- Android日常知识收集与总结之调用系统相机拍照,获得原图
- 少儿学拉丁舞有哪些好处?
- javascript面相对象编程(二):构造函数的继承
- 弹出框优化实例(alert和confirm)
- 将图片保存到系统图库
- 基于Mesos和Docker的分布式计算平台
- Sql Server 数据库恢复和日志文件的详细介绍
- 从决策树学习谈到贝叶斯分类算法、EM、HMM
- 【SSH 基础】浅谈Hibernate映射