All pastes #719127 Raw Edit

Text-based dices

public cpp v1 · immutable
#719127 ·published 2007-09-28 23:14 UTC
rendered paste body
#include <iostream>#include <iomanip>#include <stdlib.h>#include <time.h>#include <string>using namespace std;int main(){      int a;      string roll;      cout << "You can't write 'roll' in the beginning of the program. Chose a dice before doing this, otherwise the program will crash." << endl << endl;      while(true)      {            cout << "What dice do you want to use? (6, 20, 100): ";        cin >> a;                 switch (a)      {      case 6:      cout << "Write 'roll' to roll the dices: ";            if(cin>>roll)            srand(time(0));    	  cout << "Your roll\a " << rand()%6+1 << setiosflags(ios::fixed) << setprecision(2);	  cout << endl << endl;	  break;	        case 20:      cout << "Write 'roll' to roll the dices: ";            if(cin>>roll)            srand(time(0));          cout << "Your roll\a " << rand()%20+1 << setiosflags(ios::fixed) << setprecision(2);	  cout << endl << endl;	  break;	        case 100:      cout << "Write 'roll' to roll the dices: ";            if(cin>>roll)            srand(time(0));    	  cout << "Your roll\a " << rand()%100+1 << setiosflags(ios::fixed) << setprecision(2);	  cout << endl << endl;	  break;	  	  default:            system("cls");            cout << "You can't write 'roll' in the beginning of the program. Chose a dice before doing this, otherwise the program will crash." << endl << endl;      cout << "Sorry, we don't have those dices. Please choose again.";      	        cout << endl;	  break;	        }                }             system("pause");          }