需要一个运行(移动、滚动)平均算法来计算5分钟的平均轨道。 我必须全力以赴,对通过的轨道具有累积价值。
例如: 首先,5分钟后,我有10个轨道,因此,我的平均数是10个轨道。 5分钟后,我有15个轨道,因此,现在我的平均数是7.5个轨道。 另有5分钟后,我有30个轨道,因此,现在的平均数是10.8个轨道。
我的问题是,我如何在C++中执行一个时段,这样就会在大约5分钟的间隔中测出比值? 显然,我可以动用300秒的拖延。 但是,我能否在每5分钟仅发射一次事件(借方价值)的情况下拿出时间?
需要一个运行(移动、滚动)平均算法来计算5分钟的平均轨道。 我必须全力以赴,对通过的轨道具有累积价值。
例如: 首先,5分钟后,我有10个轨道,因此,我的平均数是10个轨道。 5分钟后,我有15个轨道,因此,现在我的平均数是7.5个轨道。 另有5分钟后,我有30个轨道,因此,现在的平均数是10.8个轨道。
我的问题是,我如何在C++中执行一个时段,这样就会在大约5分钟的间隔中测出比值? 显然,我可以动用300秒的拖延。 但是,我能否在每5分钟仅发射一次事件(借方价值)的情况下拿出时间?
www.un.org/Depts/DGACM/index_spanish.htm 我先前的答复:。
#define REENTRANT
//The above is neccessary when using threads. This must be defined before any includes are made
//Often times, gcc -DREENTRANT is used instead of this, however, it produces the same effect
#include <pthread.h>
char running=1;
void* timer(void* dump){
unsigned char i=0;
while(running){
for(i=0;i<300 && running;i++){
sleep(1);//so we don t need to wait the 300 seconds when we want to quit
}
if(running)
callback();//note that this is called from a different thread from main()
}
pthread_exit(NULL);
}
int main(){
pthread_t thread;
pthread_create(&thread,NULL,timer,NULL);
//do some stuff
running=0;
pthread_join(thread,NULL);//we told it to stop running, however, we might need to wait literally a second
pthread_exit(NULL);
return 0;
}
“umb”解决办法是使用苯胺read。 你们可以做一个read子,然后把它放在睡觉中。
For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...
最好、最小、最快、开放的来源、C/C++ 3d 提供方(在3ds max模型的支持下),而不是通用公平市价,
Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...
I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...
I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...
I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...
Is there anything other than DDD that will draw diagrams of my data structures like DDD does that runs on Linux? ddd is okay and runs, just kind of has an old klunky feeling to it, just wanted to ...
Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...