#include <iostream>
#include<stdlib.h>
#include<Windows.h>
using namespace std;
int main()
{
int s=2;
for(;;)
{
for (int i = 0; i < 9600000; i++)
;
Sleep(10);
}
return 0;
}
/*#include "Windows.h"
#include "stdlib.h"
#include "math.h"
const double SPLIT = 0.01;
const int COUNT = 200;
const double PI = 3.14159265;
const int INTERVAL = 300;
int main()
{
DWORD busySpan[COUNT]; //array of busy times
DWORD idleSpan[COUNT]; //array of idle times
int half = INTERVAL / 2;
double radian = 0.0;
for (int i = 0; i < COUNT; i++)
{
busySpan[i] = (DWORD)(half + (sin(PI * radian) * half));
idleSpan[i] = INTERVAL - busySpan[i];
radian += SPLIT;
}
DWORD startTime = 0;
int j = 0;
while (true)
{
j = j % COUNT;
startTime = GetTickCount();
while ((GetTickCount() - startTime) <= busySpan[j]);
Sleep(idleSpan[j]);
j++;
}
return 0;
}*/
//C++ code to make task manager generate sine graph
//#include<cstdlib>
/*#include<cmath>
#include<windows.h>
void drawSine()
{
const double PI = 3.1415926536; //pi值
const int SAMPLING_COUNT = 200; //一个周期内采样点数量
//INTERVAL对应原程序的TOTAL_AMPLITUDE
const int INTERVAL = 300; //两次采样的时间间隔
//由于正弦曲线是周期性变化,只要处理一个周期就够了。
//把曲线的一个周期划分成SAMPLING_COUNT份进行采样,
//两次采样的时间间隔为INTERVAL毫秒,
//计算每个采样点的振幅值,该值就是在这段INTERVAL时间内CPU工作时间所占的比率
// 个人倾向于使用两个常量周期PERIOD和采样数SAMPLING_COUNT,
// PERIOD值决定了形状,可以通过改变SAMPLING_COUNT值调整所画曲线的精确度
// const double PERIOD = 60000; //60000 ms 一个周期
// const int SAMPLING_COUNT = 200; //200个点
// const double INTERVAL = PERIOD / SAMPLING_COUNT; //采样间隔
const double radianIncrement = 2.0 * PI / SAMPLING_COUNT; //抽样弧度的增量
DWORD busyTime[SAMPLING_COUNT]; //busyTime 对应原程序的 busySpan
double radian = 0.0;
for (int i = 0; i < SAMPLING_COUNT; i++) {
double busyRatio = 0.5 * (1 + sin(radian));
busyTime[i] = (DWORD)(busyRatio * INTERVAL);
radian += radianIncrement;
}
DWORD startTime = 0;
for (int j = 0; ; j = (j + 1) % SAMPLING_COUNT) {
startTime = GetTickCount();
while ((GetTickCount() - startTime) <= busyTime[j]) {}
//Sleep(INTERVAL - busyTime[j]);
DWORD idleTime = INTERVAL - busyTime[j];
Sleep(idleTime);
}
}
int main()
{
drawSine();
return 0;
}