Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <time.h>
- #include <stdlib.h>
- #define SIZE_N 8
- #define SIZE_M 10
- int main()
- {
- int* N = (int*)calloc(SIZE_N, sizeof(int));
- int* M = (int*)calloc(SIZE_M, sizeof(int));
- printf("Введите ваш массив N\n");
- for(int i = 0; i < SIZE_N; i++) {
- scanf("%d", &N[i]);
- }
- printf("Введите ваш массив M\n");
- for(int i = 0; i < SIZE_M; i++) {
- scanf("%d", &M[i]);
- }
- unsigned int size = rand() % (SIZE_N) + 2;
- int* arr = (int*) calloc(size, sizeof(int));
- for(int i = 0; i < size; i++)
- {
- if(rand()%2) {
- arr[i] = N[rand() % SIZE_N];
- } else {
- arr[i] = M[rand() % SIZE_M];
- }
- }
- printf("массив полученный из массива М и N - ");
- for(int i = 0; i < size; i++) {
- printf("%d ", arr[i]);
- }
- printf("\n");
- free(N);
- free(M);
- free(arr);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement