0
time_t start;
time_t no_infection;
bool time_already_set = 0;
bool infected_or_not = 0;
int not_infected_t = 0;
私はこの変数をstructに入れています。オブジェクトの開始点と終了点に印を付けたいのですが、その差を計算するのです。スタートのために ctimeを使用してプログラムの開始点と終了点をマークするにはどうすればよいですか?
void bacteria::set_no_infection() {
if (infected_or_not == 0)
no_infection = clock();
}
私は、その時の変数は、私は同じようにそれをテストするメインプログラムで
double bacteria::get_time() {
if (infected_or_not == 1)
return ((clock() - start)/CLOCKS_PER_SEC);
else
return -1;
}
int bacteria::get_no_infection() {
if (infected_or_not = 0)
return ((clock() - no_infection)/CLOCKS_PER_SEC);
else
return -1;
}
のget関数を使用してテストプログラム中に変化しないようだ
void bacteria::set_time() {
if (infected_or_not == 1 && time_already_set!=1) {
start = clock();
time_already_set = 1;
}
}
持っていますこれは:
while (1) {
for (int i = 0; i < b.size() - 1; i++) {
bactpop[i].set_no_infection();
bactpop[i].inf(phagepop[i], bactpop[i], p);
bactpop[i].kill_the_bacteria(b, i);
cout << " " << b[i].start << " " << b[i].no_infection << endl;
}
cout << p.size() << " " << b.size() << endl;
}
] .set_no_infection();ファクタポップ[i]、bactpop [i]、p); bactpop [i] .inf(phagepop [i]、bactpop [i]、p);\t \t \t b35)。 \t \t \t cout << "" << b [i] .start << "" << b [i] .no_infection << endl; \t \t \t \tcout << p.size()<< "" << b.size()<< endl; \t} –