12345678910111213141516171819202122232425262728293031
#include<ctime> using namespace std; int main() { for (int x = 0; x < 1000000; x++) { srand(time(NULL)); int y = rand()%2+1; int z=0, g=0; while (y=2) { z++; } while (y=1) { g++; } } float perch = (g/1000000)*100; float perct = (z/1000000)*100; cout << "Number of heads = " << g << ", percent = " << perch << "%" << endl; cout << "Number of tails = " << z << ", percent = " << perct << "%" << endl; system("pause"); return 0; }