Advertisement
PonaFly

Untitled

May 29th, 2017
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. int main(){
  5.  int a,b,n;
  6.  scanf ("%d",&a);
  7.  scanf ("%d",&b);
  8.  scanf ("%d",&n);
  9.  printf("\n");
  10.  GenArray(a,b,n);
  11.  
  12. }
  13.  
  14. int GenArray(int a,int b,int n){
  15. int *ar,i;
  16.  
  17. srand(time(NULL));
  18.   for(i=0;i<n;i++){
  19.     if (ar = (int *) malloc(n * sizeof(int))){
  20.     ar[i]= get_rand(a,b) ;
  21.     printf("%d\n",ar[i]);
  22.     return ar;
  23.     }
  24.     else return NULL;
  25.   }
  26.  
  27. }
  28.  
  29.  
  30. int get_rand(int min, int max){
  31. return rand() % (max - min + 1) + min;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement