Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. #include <cstdlib>
  4. /*4.    Napisz program symulujący rzut kostką do gry (20 rzutów).
  5. Wyniki zapisuj do tablicy, a potem wyświetli.*/
  6. using namespace std;
  7. int main() {
  8.     srand(time(0));
  9.     int wyniki[20];
  10.     cout<<"\n   /------KOSTKA------\\\n";
  11.     for (int i= 0 ; i <10; i++){
  12.         wyniki[i]= (rand() %6)+1;
  13.     }
  14.     for (int g = 0; g < 10; g++){
  15.         cout<<"   |rzut numer"<<g+1;
  16.         if(g < 9){
  17.             cout<<" ";
  18.         }
  19.         cout<<":  "<<wyniki[g]<<"  |\n";
  20.     }
  21.     cout<<"   |------------------|\n";
  22.     int suma = 0;
  23.     int max=0;
  24.     int min=9;
  25.     for (int y = 0; y < 10; y++){
  26.         suma = suma + wyniki[y];
  27.        
  28.         if (wyniki[y]>wyniki[max]){
  29.             max = y;
  30.         }
  31.         if (wyniki[y]<wyniki[min]){
  32.             min = y;
  33.         }
  34.     }
  35.     cout<<"   |-----wynik to: "<<suma<<"\n";
  36.     cout<<"   |-----min rzut to: "<<min+1<<"\n";
  37.     cout<<"   |-----max rzut to: "<<max+1<<"\n";
  38.     cout<<"   \\------------------/\n";
  39.    
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement