Suppose I put 10
in the length of the vectors in the following code.
The problem is that even if I put 10
in the length, I can only enter 6
coordinates to the vector using the keyboard.
Why does that problem happen?
int main(){
int i=0;
int j=0;
int largovector=0;
int vector1[largovector];
int vector2[largovector];
int minimo=999999;
int maximo=-999999;
int contador=1;
printf("Ingrese el largo del vector\n"); //Definimos el largo del vector
scanf("%d",&largovector);
for(j=1; j<=largovector; j++) //Definimos los numeros del vector
{
printf ("Ingrese el valor de la coordenada %d del vector: \n",j);
scanf ("%d",&vector1[j]);
}
for(i=largovector; i>=0; i--,contador++) //Asignar los valores del vector1 al vector2
{
vector2[contador]=vector1[i];
}
printf("El vector 1 esta formado por los numeros: ");//Imprimimos el primer vector
for(j=1; j<=largovector; j++)
{
printf(" %d ",vector1[j]);
}
printf("\n");
printf("El vector 2 esta formado por los numeros: "); //Imprimimos el segundo vector
for (i=1; i<=largovector; i++)
{
printf(" %d ",vector2[i]);
}
printf("\n");
}