Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main(void)
- {
- int n, g = 0, i = 0;
- int array[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- int array1[10];
- scanf_s("%d", &n);
- switch (n)
- {
- case 1:
- {
- for (i; i < 10; i++)
- {
- if (array[i] % 2 != 0)
- {
- array1[g] = array[i];
- g++;
- }
- }
- for (i = 0; i < g; i++)
- printf("%d ", array1[i]);
- break;
- }
- case 2:
- {
- for (i; i < 10; i++)
- {
- if (array[i] % 2 == 0)
- {
- array1[g] = array[i];
- g++;
- }
- }
- for (i = 0; i < g; i++)
- printf("%d ", array1[i]);
- break;
- }
- case 3:
- {
- for (i; i < 10; i++)
- {
- if (array[i] % 3 != 0)
- {
- array1[g] = array[i];
- g++;
- }
- }
- for (i = 0; i < g; i++)
- printf("%d ", array1[i]);
- break;
- }
- default:
- {
- for (i; i < 10; i++)
- array[i] = 0;
- for (i = 0; i < 10; i++)
- printf("%d ", array[i]);
- }
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement