Advertisement
Kajoj

Std16.01.14

Jan 14th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. void losuj(int *tab, int n)
  6. {
  7.     srand (time(NULL));
  8.     int i;
  9.     for (i=0; i<n;i++)
  10.     {
  11.         tab[i]=rand()%9+1;
  12.     }
  13. }
  14.  
  15. int main()
  16. {
  17.     int n,i, *tab;
  18.     printf("Podaj rozmiar tablicy:");
  19.     scanf("%d",&n);
  20.     tab=(int *)malloc(sizeof(int)*n);
  21.     losuj(tab, n);
  22.     for (i=0; i<n; i++)
  23.         printf("%d ",tab[i]);
  24.     free(tab);
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement