Advertisement
Guest User

sxdf

a guest
Nov 25th, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.02 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.             puts("wyniki: ");
  24.     for (i=0;i<31;i++)
  25.     {
  26.         tab[i]=rand()%2;
  27.  
  28.         printf("%d",tab[i]);
  29.  
  30.     }
  31. }
  32.  
  33. void wyswietl(int tab[31], int i)
  34. {
  35.     for (i=0;i<31;i++)
  36.     {
  37.       if (tab[i]==1)
  38.       {
  39.           printf("Rzut nr %d wynik: Orzel\n",i);
  40.       }
  41.       if (tab[i]==0)
  42.       {
  43.           printf("Rzut nr %d wynik: Reszka\n",i);
  44.       }
  45.     }
  46. }
  47.  
  48. int main()
  49. {
  50.  
  51.     int ROZMIAR=0,i=0;
  52.     pytanie(&ROZMIAR);
  53.     int tab[ROZMIAR];
  54.     printf("ile = %d\n",ile);
  55.     rzuty(tab,i);
  56.     wyswietl(tab,i);
  57.     return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement