Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdbool.h>
- #define MAX_ARRAY_SIZE 100
- int CheckOddOrEven(int type, int x[], int y[], int z[]); // 1 - ODD, 2 - EVEN
- void main()
- {
- int BigOne[MAX_ARRAY_SIZE],
- Even[MAX_ARRAY_SIZE],
- Odd[MAX_ARRAY_SIZE];
- for(int i = 0; i < MAX_ARRAY_SIZE; i++)
- {
- BigOne[i] = rand() % 10;
- }
- PrintInConsole(BigOne, Even, Odd);
- }
- int CheckOddOrEven(int type, int x[], int y[], int z[]) // 1 - ODD, 2 - EVEN
- {
- int even = 0, odd = 0;
- for(int i = 0; i < MAX_ARRAY_SIZE; i++)
- {
- if(x[i] % 2 == 0)
- {
- y[even] = x[i];
- even++;
- }
- else
- {
- z[odd] = x[i];
- odd++;
- }
- }
- if(type == 1) return odd;
- else if(type == 2) return even;
- }
- void PrintInConsole(int x[], int y[], int z[])
- {
- printf("Lyginiai skaiciai: \n");
- for(int i = 0; i < CheckOddOrEven(2, x, y, z); i++)
- printf("%d ", y[i]);
- printf("\n");
- printf("Nelyginiai skaiciai: \n");
- for(int i = 0; i < CheckOddOrEven(1, x, y, z); i++)
- printf("%d ", z[i]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement