Advertisement
Guest User

Untitled

a guest
May 27th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <ctime>
  4.  
  5. using namespace std;
  6. bool noAmoi();
  7. void Wurf_Eingaben(int Sp[6]);
  8. void Wurf_Erzeugen(int Computer[6]);
  9. void Wurf_Ausgeben(int Computer[6]);
  10. int Punkt_Erster(int Sp1[6],int Sp2[6]);
  11. void main () {
  12. cout<<"* * * W u e r f e l s p i e l * * *";
  13.  
  14. int Sp[6];
  15. int Computer[6];
  16. int Punkte_Sp;
  17. int Punkte_Computer;
  18. do{
  19. Wurf_Eingaben(Sp);
  20. Wurf_Erzeugen(Computer) ;
  21. cout<<"\nComputer :";
  22. Wurf_Ausgeben(Computer);
  23. cout<<"\nSpieler : ";
  24. Wurf_Ausgeben(Sp);
  25. Punkte_Sp=Punkt_Erster(Sp,Computer);
  26.  
  27. Punkte_Computer = Punkt_Erster(Sp,Computer);
  28. cout<<"\n"<<Punkte_Sp;
  29.  
  30.  
  31.  
  32. }while (noAmoi());
  33.  
  34.  
  35.  
  36.  
  37.  
  38. }
  39.  
  40. bool noAmoi() {
  41. cout<<"\n\nWollen Sie das Programm neustarten (j/n)";
  42. return toupper(_getch())!='N';
  43.  
  44. }
  45. void Wurf_Eingaben(int Sp[6]) {
  46. for(int i=1;i<=5;i++){
  47. cout<<"\nIhr " << i <<".Wurf : ";
  48. cin>>Sp[i];
  49. }
  50. }
  51.  
  52.  
  53. void Wurf_Erzeugen(int Computer[6]) {
  54. srand((unsigned)time(0));
  55. for(int i=1;i<=5;i++){
  56. Computer[i]=rand()%6+1 + rand()%6+1;
  57.  
  58.  
  59. }
  60.  
  61. }
  62.  
  63.  
  64.  
  65. void Wurf_Ausgeben(int Computer[6] ) {
  66. for(int i=1;i<=5;i++){
  67. cout<<Computer[i]<<" ";
  68.  
  69. }
  70. }
  71.  
  72. int Punkt_Erster(int Sp1[6],int Sp2[6]) {
  73. int Punkte_Sp1;
  74.  
  75. for(int i=1;i<=5;i++){
  76.  
  77.  
  78.  
  79. if(Sp1[i]>Sp2[i])
  80. Punkte_Sp1=Punkte_Sp1+3;
  81.  
  82.  
  83. if(Sp1[i]==Sp2[i])
  84. Punkte_Sp1=Punkte_Sp1+1;
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92. }
  93. return Punkte_Sp1;
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement