-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
67 lines (46 loc) · 1.28 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// main.cpp
// chessPieces
//
// Created by Miguel Sacristán on 13/1/17.
//
//
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <thread>
#include "horse.h"
using namespace std;
int main(int argc, const char * argv[]) {
//Set seed for rand and precision output (Not really necesary but nice to have)
cout<<setprecision(15);
srand(time(0));
//Variables
int long horses;
int x;
int y;
int long long sum=0;
//Ask the user the parameters
cout<<"---Calculator of Average Number of steps to come back for a horse---"<<endl<<endl;
cout<<"How many times do you want to run the horse = ";
cin>>horses;
cout<<endl;
cout<<"Starting 'x' position (Example A=1 & H=8) = ";
cin>>x;
cout<<endl;
cout<<"Starting 'y' position (1-8) = ";
cin>>y;
cout<<endl<<endl;
x--;
y--;
//Object (We will reuse it all the time)
horse mylittlepony(x,y);
for (int i=0; i<horses; i++) {
sum += mylittlepony.numberOfMovesToComeBack();
}
//Do the average and extracted
double average = double(sum)/double(horses);
cout<<"Average Number of moves to come back = "<<average<<endl;
return 0;
}