Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- #include <cstdlib>
- /*4. Napisz program symulujący rzut kostką do gry (20 rzutów).
- Wyniki zapisuj do tablicy, a potem wyświetli.*/
- using namespace std;
- int main() {
- srand(time(0));
- int wyniki[20];
- cout<<"\n /------KOSTKA------\\\n";
- for (int i= 0 ; i <10; i++){
- wyniki[i]= (rand() %6)+1;
- }
- for (int g = 0; g < 10; g++){
- cout<<" |rzut numer"<<g+1;
- if(g < 9){
- cout<<" ";
- }
- cout<<": "<<wyniki[g]<<" |\n";
- }
- cout<<" |------------------|\n";
- int suma = 0;
- int max=0;
- int min=9;
- for (int y = 0; y < 10; y++){
- suma = suma + wyniki[y];
- if (wyniki[y]>wyniki[max]){
- max = y;
- }
- if (wyniki[y]<wyniki[min]){
- min = y;
- }
- }
- cout<<" |-----wynik to: "<<suma<<"\n";
- cout<<" |-----min rzut to: "<<min+1<<"\n";
- cout<<" |-----max rzut to: "<<max+1<<"\n";
- cout<<" \\------------------/\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement