Created
August 28, 2013 08:52
-
-
Save itsPG/6363748 to your computer and use it in GitHub Desktop.
by PG @ SENSE Lab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
int flower[] = {1,2,3,4,5,6,7,8}; | |
bool check_pick() | |
{ | |
for (int i = 3; i < 8; i++) | |
if (flower[i] > flower[0] && flower[i] > flower[1] && flower[i] > flower[2]) | |
return flower[i] == 8; | |
return false; | |
} | |
int main() | |
{ | |
int total_times = 0, success_time = 0; | |
while (1) | |
{ | |
++total_times; | |
if (check_pick()) success_time++; | |
if (!next_permutation(flower, flower + 8)) break; | |
} | |
cout << success_time << " / " << total_times << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment