How to Write a C program from standard input loading integers, until a 0 and place them in a series. Then, from a series of projects all the elements of a [i] having the following properties: i> 0 and a [i] is less than all of the elements that precede it in a series. After ejection, the program prints the contents of the current series. Assume that the series will not have more than 20 elements.
/*
Napisati program koji sa standardnog ulaza ucitava cele brojeve, dok se ne unese 0 i smesta ih u niz. Potom, iz niza a izbacuje sve elemente a[i] koji imaju sledece svojstvo: i > 0 i a[i] je manji od svih elemenata koji mu prethode u nizu a. Nakon izbacivanja, program ispisuje trenutni sadrzaj niza. Pretpostaviti da niz nece imati vise od 20 elemenata.
*/
#include <stdio.h>
#define MAX 20
int main ( ) {
int a[MAX], noviNiz[MAX];
int i = 0, brojClanova, j, k;
while (scanf ("%d", &a[i]) != 0) {
i++;
}
brojClanova = i;
noviNiz[0] = a[0];
for (i = 1, k = 1; i < brojClanova; i++) {
for (j = 0; j < i; j++) {
if (a[i] > a[j]) {
noviNiz[k] = a[j];
k++;
break;
}
}
}
brojClanova = i;
for (i = 0; i < brojClanova; i++) {
printf ("%d ", noviNiz[i]);
}
printf ("\n");
return 0;
}