fork download
  1. #include <iostream>
  2. #include <stdlib.h>
  3.  
  4. using namespace std;
  5.  
  6. string calculation()
  7. { string mortalityChits[36] = {"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","-","-","-","-","x2","x2"};
  8. int mortalityResult; // mortalityResult = rand() %36;
  9. mortalityResult = 35; // for testing only. Delete afterwards.
  10.  
  11. string drawnChit = mortalityChits[mortalityResult];
  12. string drawnChit1; string drawnChit2;
  13.  
  14. if (drawnChit != "-" && drawnChit != "x2") {
  15. string returnText = string("The computer has drawn the chit '") + drawnChit + "'.";
  16. cout << returnText;
  17. return returnText;
  18.  
  19. }
  20.  
  21. do
  22. {
  23. cout << "The computer has drawn the 'x2' chit." << endl;
  24. cout << "Two more chits will be drawn.\n" << endl;
  25. mortalityResult = rand() %36;
  26. cout << mortalityResult <<endl;
  27. drawnChit1 = mortalityChits[mortalityResult];
  28. cout << "The first draw is the chit '" << drawnChit1 << "'. "; mortalityResult = rand() %36;
  29. cout << endl << mortalityResult << endl;
  30. drawnChit2 = mortalityChits[mortalityResult];
  31. cout << "The second draw is the chit '" << drawnChit2 << "'." << endl;
  32. } while (drawnChit1 == "x2" || drawnChit2 == "x2"); return "The mortality chits have been drawn. The corresponding senators are dead.";
  33.  
  34. }
  35.  
  36. int main() {
  37. calculation();
  38. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
The computer has drawn the 'x2' chit.
Two more chits will be drawn.

19
The first draw is the chit '20'. 
34
The second draw is the chit 'x2'.
The computer has drawn the 'x2' chit.
Two more chits will be drawn.

9
The first draw is the chit '10'. 
7
The second draw is the chit '8'.