#include <stdio.h>#include <iostream>#include <malloc.h>const int N = 10;int main(){setlocale(LC_ALL, "RUS");int i, j=0, n=0;int array[N];int *a;puts("Исходный массив:");for (i=0; i<N; i++) {printf("Введите %d элемент:", i);scanf("%d", &array[i]);}system("cls");puts("Исходный массив:");for (i=0; i<N; i++) {printf("%d ", array[i]);}printf("");for (i=0; i<N; i++)if (array[i] == 0)n++; printf("Новый массив:");a = (int *)malloc(n*sizeof(int));for (i=0; i<N; i++) if (array[i] == 0) { a[j] = i; printf("%d ", a[j]); j++; }free(a);printf("");system("pause");return 0;}
Тестовое решение:Исходный массив:5 0 3 6 0 0 2 1 0 5Новый массив:1 4 5 8Для продолжения нажмите любую клавишу . . .