SHARE
TWEET

Sergeeeeey

allekco Jun 18th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <math.h>
  5. #include <stddef.h>
  6. #include <time.h>
  7.  
  8.  
  9. int randomazer (int min, int max){
  10.     int random;
  11.     random = rand();
  12.     random = ((float)random / RAND_MAX)*(max-min)+min;
  13.     return(random);
  14. }
  15.  
  16. void change (int *A, int i, int size){
  17.     int tmp;
  18.     tmp = A[i];
  19.     A[i] = A[size-1];
  20.     A[size-1] = tmp;
  21. }
  22.  
  23. void output_mass(int *A, int size){
  24.     int i;
  25.     for (i=0; i<size; i++){
  26.         printf ("%d ", A[i]);  
  27.     }
  28.     printf ("\n");
  29. }
  30.  
  31. int main(void) {
  32.     srand(time(NULL));
  33.     int min, max, size, i;
  34.     scanf ("%d", &size);
  35.     int *A; //ukazatel na massiv
  36.     min = 5;
  37.     max = 20;
  38.     A = (int*)malloc(size * sizeof(int));
  39.    
  40.     for (i=0; i<size; i++){
  41.         A[i] = randomazer (min, max);  
  42.     }
  43.     output_mass (A, size);
  44.     scanf ("%d", &i);
  45.     change (A, i, size);
  46.     output_mass (A, size);
  47.        
  48.     return 0;
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top