#include #include #include int roll_dice(){ int die; die = (rand() % 6) + 1; return die; } void print_die(int num){ cout << "---\n|"; switch(num){ case 1: cout << " |\n| . |\n| "; break; case 2: cout << ". |\n| |\n| ."; break; case 3: cout << ". |\n| . |\n| ."; break; case 4: cout << ". .|\n| |\n|. ."; break; case 5: cout << ". .|\n| . |\n|. ."; break; case 6: cout << "...|\n| |\n|..."; break; } cout << "|\n---" << endl; } void play(){ int dice[5]; int attempts = 1; int pedals, i, guess; srand(time(NULL)); do{ pedals = 0; for(i = 0; i < 5; i++){ dice[i] = roll_dice(); if(dice[i] == 3) pedals += 2; else if(dice[i] == 5) pedals += 4; print_die(dice[i]); } cin >> guess; if(guess == pedals) cout << "congrats, achieved in " << attempts << " attempts" << endl; else{ cout << "sorry, there were " << pedals << " pedals" << endl; attempts++; } } while(guess != pedals); cout << "again? (yes (1) / no (0)) ::>"; cin >> guess; if(guess == 1) play(); } int main(){ play(); return 0; }