بابلز لرن مرجع آموزش های تخصصی
سلام، سورس کد پروژه:
#include <iostream>
#include <cstdlib>
#include <ctime>
int main() {
srand(time(0)); // Set the random seed based on the current time
int counter = 0;
for (int i = 0; i < 1000; ++i) {
int dice1 = rand() % 6 + 1; // Random numbers between 1 and 6
int dice2 = rand() % 6 + 1;
if (dice1 + dice2 == 12) {
counter++;
}
}
std::cout << "The number of times the sum of two dice is 12: " << counter << std::endl;
return 0;
}