Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. /*******************************************************************************
  2. * *
  3. * created by Alisher Khodzhahanov * *
  4. * *
  5. * ICQ: 649946128 *
  6. * mail: monsherko@yahoo.com *
  7. * telegram: monsherko *
  8. * *
  9. * *
  10. ********************************************************************************/
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17. // g++ main.cpp -o output
  18.  
  19. #include <stdio.h>
  20. #include <time.h>
  21. #include <stdlib.h>
  22.  
  23. #define SIZE_N 8
  24. #define SIZE_M 10
  25. int main()
  26. {
  27. int* N = (int*)calloc(SIZE_N, sizeof(int));
  28. int* M = (int*)calloc(SIZE_M, sizeof(int));
  29.  
  30. printf("Введите ваш массив N\n");
  31. for(int i = 0; i < SIZE_N; i++) {
  32. scanf("%d", &N[i]);
  33. }
  34. printf("Введите ваш массив M\n");
  35. for(int i = 0; i < SIZE_M; i++) {
  36. scanf("%d", &M[i]);
  37. }
  38.  
  39. unsigned int size = rand() % (SIZE_N) + 2;
  40. int* arr = (int*) calloc(size, sizeof(int));
  41.  
  42. for(int i = 0; i < size; i++)
  43. {
  44. if(rand()%2) {
  45. arr[i] = N[rand() % SIZE_N];
  46. } else {
  47. arr[i] = M[rand() % SIZE_M];
  48. }
  49. }
  50.  
  51. printf("массив полученный из массива М и N - ");
  52. for(int i = 0; i < size; i++) {
  53. printf("%d ", arr[i]);
  54. }
  55.  
  56. printf("\n");
  57.  
  58. free(N);
  59. free(M);
  60. free(arr);
  61. return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement