Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication9.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include "mclass.h"
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- #define N 1000
- #define T 25
- using namespace std;
- int main()
- {
- int stat = 0;
- srand(time(NULL));
- bool a[25] = {true, true, true, true, true,
- false, false, false, false, false, false,
- true, true, false, false, false, false,
- true, true, true, true, false, true, false, false};
- bool flag = false;
- int lastexit = 0;
- int shorte = 25;
- int i = 0, u = 0, g = 0;
- while (N > i) {
- mclass *mm = new mclass();
- int steps = 0;
- while (T > u) {
- float r = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
- if (r > 0.5) {
- if (a[steps]) {
- mm->pluss();
- }
- else {
- mm->minuss();
- }
- }
- else {
- if (!a[steps]) {
- mm->pluss();
- }
- else {
- mm->minuss();
- }
- }
- if (mm->exit()) {
- if (u > lastexit)
- lastexit = u + 1;
- if (u < shorte)
- shorte = u + 1;
- stat++;
- break;
- }
- cout << i << " : " << u + 1 << " : " << r << endl;
- u++;
- }
- u = 0;
- i++;
- }
- cout << "Last exit: " << lastexit << endl;
- cout << "Short: " << shorte << endl;
- cout << "Stat: " << stat << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement