#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;
}
阅读(796) | 评论(0) | 转发(0) |