diff --git a/exercises/risk-risiko.cpp b/exercises/risk-risiko.cpp index 3166f05..d2e5d44 100644 --- a/exercises/risk-risiko.cpp +++ b/exercises/risk-risiko.cpp @@ -27,3 +27,63 @@ M 3 vs 3 => blue win O 2 vs 1 => red win */ + +#define EXIT_SUCCESS 0 +#include +#include +#include + +using namespace std; + +void swap(int *A, int i, int j){ + + int tmp = A[i]; + A[i] = A[j]; + A[j] = tmp; + +} + +void sort(int *A, int n){ + + for(int i = 0; i < n; i++){ + for(int j = 0; j < n; j++){ + + if(A[i] > A[j]) swap(A,i,j); + } + } + +} +int main(){ + + srand(time(NULL)); + + int RedRolls[3]; + int BlueRolls[3]; + + for(int i = 0; i < 3; i++){ + + RedRolls[i] = int(rand()%6) + 1; + BlueRolls[i] = int(rand()%6) + 1; + + } + + sort(RedRolls,3); + sort(BlueRolls,3); + + cout << "Red Dices:"< " << (BlueRolls[0] >= RedRolls[0] ? "Blue wins" : "Red Wins")<< endl; + cout << "M "<< RedRolls[1] <<" vs "<< BlueRolls[1] << " => " << (BlueRolls[1] >= RedRolls[1] ? "Blue wins" : "Red Wins")<< endl; + cout << "O "<< RedRolls[2] <<" vs "<< BlueRolls[2] << " => " << (BlueRolls[2] >= RedRolls[2] ? "Blue wins" : "Red Wins")<< endl; + + return EXIT_SUCCESS; +} \ No newline at end of file