Make an algorithm that reads a set of 30 integer numeric values and distributes them between two vectors, separating the positive numbers from the negative ones. The vectors must have 30 positions each. Show the vectors at the end of processing.
int vetPos[3], vetNeg[3];
int valor, i, cont;
cont = 1;
do{
printf("Informe um valor: ");
scanf("%d",&valor);
if(valor >= 0){
//insere no vetor positivo
for(i=0;i<3;i++){
vetPos[i] = valor;
}
}else if(valor < 0){
//insere no vetor negativo
for(i=0;i<3;i++){
vetNeg[i] = valor;
}
}
valor = 0;
cont++;
}while(cont<=3);
//saida de dados
printf("Os números positivos digitados foram: ");
for(i=0;i<3;i++){
printf("%3d",vetPos[i]);
}
printf("\nOs números negativos digitados foram: ");
for(i=0;i<3;i++){
printf("%3d",vetNeg[i]);
}
No do..while
made up to 3 just for testing.
In the compiler the result was this:
I understand that this error occurs because it needs something like a delimiter for the vector, but I'm not sure if that's all, what can I do?