All pastes #831695 Raw Edit

Untitled

public cpp v1 · immutable
#831695 ·published 2007-12-25 08:04 UTC
rendered paste body
#include <iostream.h>#include <stdlib.h>#include <time.h>int roll_dice(){	int die;	srand(time(NULL));	die = (rand() % 6) + 1;	return die;}void print_die(int num){	select(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 << endl;}void play(){	int dice[5];	int attempts = 0;	int pedals, i, guess;		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? >>";	cin >> guess;		if(guess == 1)		play();}int main(){	play();	return 0;}