Advertisement
Guest User

Untitled

a guest
May 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. // ConsoleApplication9.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "mclass.h"
  6. #include <iostream>
  7. #include <cstdlib>
  8. #include <ctime>
  9. #define N 1000
  10. #define T 25
  11.  
  12. using namespace std;
  13.  
  14. int main()
  15. {
  16. int stat = 0;
  17. srand(time(NULL));
  18. bool a[25] = {true, true, true, true, true,
  19. false, false, false, false, false, false,
  20. true, true, false, false, false, false,
  21. true, true, true, true, false, true, false, false};
  22. bool flag = false;
  23. int lastexit = 0;
  24. int shorte = 25;
  25. int i = 0, u = 0, g = 0;
  26. while (N > i) {
  27. mclass *mm = new mclass();
  28. int steps = 0;
  29. while (T > u) {
  30.  
  31. float r = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  32.  
  33. if (r > 0.5) {
  34. if (a[steps]) {
  35. mm->pluss();
  36. }
  37. else {
  38. mm->minuss();
  39. }
  40. }
  41. else {
  42. if (!a[steps]) {
  43. mm->pluss();
  44. }
  45. else {
  46. mm->minuss();
  47. }
  48. }
  49. if (mm->exit()) {
  50. if (u > lastexit)
  51. lastexit = u + 1;
  52. if (u < shorte)
  53. shorte = u + 1;
  54. stat++;
  55. break;
  56. }
  57. cout << i << " : " << u + 1 << " : " << r << endl;
  58. u++;
  59.  
  60.  
  61. }
  62. u = 0;
  63. i++;
  64. }
  65. cout << "Last exit: " << lastexit << endl;
  66. cout << "Short: " << shorte << endl;
  67. cout << "Stat: " << stat << endl;
  68. system("pause");
  69. return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement