| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 455 人关注过本帖
标题:一道考试题,大侠帮忙看看!
只看楼主 加入收藏
dqpicsl
Rank: 1
等 级:新手上路
帖 子:7
专家分:8
注 册:2011-8-29
结帖率:100%
收藏
 问题点数:0 回复次数:1 
一道考试题,大侠帮忙看看!
What does this code do, and is there anything wrong with it?

unsigned char somebody_elses_function(void)
{
  static unsigned int max_fast_vrect = 0;
  static unsigned int min_fast_vrect = 0;
  static unsigned int last_fast_vrect = 0;
  static signed char slope = 0;
  unsigned int fast_vrect = get_adc( VRECT_FAST );

  if(slope > 0)
  {
  if(fast_vrect <= last_fast_vrect)
  {
  if(slope++ > VRECT_SLOPE_DEBOUNCE)
  {
  slope = -1;
  max_fast_vrect = last_fast_vrect;
  }
  }
  else
  {
  last_fast_vrect = fast_vrect;
  }
  }
  else if(slope < 0)
  {
  if(fast_vrect >= last_fast_vrect)
  {
  if(slope-- < -VRECT_SLOPE_DEBOUNCE)
  {
  slope = 1;
  min_fast_vrect = last_fast_vrect;
  }
  }
  else
  {
  last_fast_vrect = fast_vrect;
  }
  }
  else
  {
  slope = 1;
  }

  if((min_fast_vrect >= max_fast_vrect) ||
  (max_fast_vrect < MIN_V_RECT) ||
  ((max_fast_vrect - min_fast_vrect) <= (max_fast_vrect + min_fast_vrect) >> (1+2))
  )
  {
  return TRUE;
  }

  return FALSE;
 
 
 
搜索更多相关主题的帖子: anything 考试题 wrong 
2011-08-29 12:18
dqpicsl
Rank: 1
等 级:新手上路
帖 子:7
专家分:8
注 册:2011-8-29
收藏
得分:0 
我没看懂,请高手指点一下啊!
2011-08-29 20:23
快速回复:一道考试题,大侠帮忙看看!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.051283 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved