Advertisement
Guest User

SFD

a guest
Nov 25th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5.  
  6.  
  7. /// napisz program ktory spyta uzytkownika ile razy chce rzucic moneta nastepnie
  8. /// wyliczy ile razy wypadl orzel a ile reszka
  9. /// przyjmij wartosc 1 jako orzel a 0 jako reszka
  10. /// wypisz kazdy rzut jako tablice o N rzutach
  11.  
  12. int pytanie(int *ROZMIAR)
  13. {
  14.     printf("Ile razy chcesz rzucic moneta: ");
  15.     scanf("%d",ROZMIAR);
  16.  
  17. }
  18.  
  19.  
  20. void rzuty (int tab[ROZMIAR], int i)
  21. {
  22.     srand(time(NULL));
  23.     for (i=0;i<ROZMIAR;i++)
  24.     {
  25.         tab[i]=rand()%2;
  26.  
  27.     }
  28. }
  29.  
  30. void wyswietl(int tab[ROZMIAR], int i)
  31. {
  32.     for (i=0;i<ROZMIAR;i++)
  33.     {
  34.       if (tab[i]==1)
  35.       {
  36.           printf("Rzut nr %d wynik: Orzel\n",i);
  37.       }
  38.       if (tab[i]==0)
  39.       {
  40.           printf("Rzut nr %d wynik: Reszka\n",i);
  41.       }
  42.     }
  43. }
  44.  
  45. int main()
  46. {
  47.  
  48.     int ROZMIAR=0,i=0;
  49.     pytanie(&ROZMIAR);
  50.     int tab[ROZMIAR];
  51.     printf("ile = %d\n",ile);
  52.     rzuty(tab,i);
  53.     wyswietl(tab,i);
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement