Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include<stdlib.h>
  2. #include<stdio.h>
  3. #include<time.h>
  4.  
  5.  
  6. const int liczba = 20;
  7.  
  8. main(){
  9.  
  10. double a, b, c;
  11. int i,j,k,l;
  12. int m, n;
  13.  
  14. double **array;
  15. array = (double**)malloc(n*sizeof(double));
  16.  
  17. for(i=0; i<liczba; i++){
  18. array[i] = (double*)malloc(m*sizeof(double));
  19. }
  20.  
  21. srand(time(NULL));
  22.  
  23. printf("Podaj dwie liczby rzeczywiste\n");
  24. scanf("%lf %lf", &a, &b);
  25. printf("Losowe liczby rzeczywiste z zakresu : %lf - %lf\n", a, b);
  26.  
  27. for(i=0;i<liczba;i++){
  28.  
  29. c = (double)rand()/(RAND_MAX+a)*b;
  30.  
  31. printf("%.3lf \n",c);
  32.  
  33. #ifdef DEBUG
  34. if(c<a || c>b) {
  35. printf("Blad generacji %lf\n", c); exit(0);
  36. }
  37. #endif
  38.  
  39. }
  40.  
  41. printf("Podaj dwie liczby calkowite\n");
  42. scanf("%d %d", &j, &k);
  43. printf("Losowe liczby calkowite z zakresu : %d - %d\n", j, k);
  44.  
  45. for(i=0;i<liczba;i++){
  46.  
  47. l = (int)rand()/(RAND_MAX+a)*b;
  48.  
  49. printf("%d \n",l);
  50.  
  51. #ifdef DEBUG
  52. if(l<j || l>k) {
  53. printf("Blad generacji %d\n", l); exit(0);
  54. }
  55. #endif
  56.  
  57. }
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement