Advertisement
PonaFly

Untitled

May 29th, 2017
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 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.  int *ar= GenArray(a,b,n);
  11. }
  12.  
  13. int *GenArray(int a,int b,int n){
  14. int *ar,i;
  15. srand(time(NULL));
  16.   for(i=0;i<n;i++){
  17.     if (ar = (int *) malloc(n * sizeof(int))){
  18.     ar[i]= get_rand(a,b);
  19.     printf("%d\n",ar[i]);
  20.     return ar;
  21.     }
  22.     else return NULL;
  23.   }
  24. }
  25.  
  26.  
  27. int get_rand(int min, int max){
  28. return rand() % (max - min + 1) + min;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement