dice3 code example

Example: dice3

#include
#include
#include 
#include
#include
#include
#include 
int main( ) {
    std::cout << "enter seeding number: " ; 
    int num_seed = 0 ;
    std::cin >> num_seed ;
    srand( num_seed ) ;
    std::cout << "enter numbers of tries: ";
    int tries = 0 ;
    std::cin >> tries ;
    std::cout << "enter numbers of asterikes: "; 
    int asterikes = 0 ;
    std::cin >> asterikes ;
    double sum_of_three_dices , average_of_three_dices,sigme_dices_powered, variation, standard_dev = 0.0 ;
    std::vector vec_of_three_dice(19,0);
    for(size_t i = 0; i < tries ; i++)
    {
        int dice_one = rand()%6 + 1 ;
        int dice_two = rand()%6 + 1 ;
        int dice_three = rand()%6 + 1 ;
        vec_of_three_dice[dice_one + dice_two + dice_three] += 1 ;
        sum_of_three_dices += dice_one + dice_two +dice_three ;
        average_of_three_dices = sum_of_three_dices / tries ;
        sigme_dices_powered += pow(dice_one + dice_two + dice_three ,2);
        variation = sigme_dices_powered/tries - pow(average_of_three_dices,2);
        standard_dev = sqrt(variation);
    }

    average_of_three_dices = sum_of_three_dices / tries ;
    std::cout << "average_of_three_dices is: " <(vec_of_three_dice.at(i) * asterikes)/max_value ; j++ ){
           std::cout << "*";
       }
        std::cout << std::endl;


    } 
    return 0 ;
}

Tags:

Misc Example