Chinaunix首页 | 论坛 | 博客
  • 博客访问: 542159
  • 博文数量: 104
  • 博客积分: 4131
  • 博客等级: 上校
  • 技术积分: 1137
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-31 15:05
文章分类

全部博文(104)

文章存档

2011年(13)

2010年(23)

2009年(68)

我的朋友

分类: WINDOWS

2009-12-07 17:25:59

#include   
#include   
#include    
#include
#include  
using namespace std;  
 
#define count (int)180    //时间数组的个数  
int main()  
{  
     const double PI=3.1416;    
     int idle[count];  
     int busy[count];  
     float delta=2*PI/count;  
     float alpha=0;  
     /* 
       给循环和sleep各生成一列时间数组  
       busy按照正弦规律变化,busy和对应的sleep的和不变  
     */ 
     for(int i=0;i     {  
        busy[i]=count*(sin(alpha)+1)/2;  
        idle[i]=count-busy[i];  
        alpha=alpha+delta;  
        cout<     }  
       
     int j=0;  
     int st_time;  
     while(true)  
     {     
         j=j%count;  
         st_time=clock();     //起始时间   
         while((clock()-st_time)         Sleep(idle[j]);  
         j++;  
     }         
     system("PAUSE");  
     return 0;  
}  
阅读(747) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~