3
I’m asking a question that asks the following:
So I made this algorithm:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i, j, x=0;
int vetor[x];
printf ("Digite o tamanho do vetor:\n");
scanf ("%d", &x);
for (i=0; i<x; i++)
{
printf ("\nDigite o numero de posicao %d do vetor:\n", i);
scanf ("%d", &vetor[i]);
}
system("cls");
for (i=0; i<x; i++)
{
for (j=i+1; j<x; j++)
{
if (vetor[i] == vetor[j])
printf ("\nO numero %d se repete\n", vetor[i]);
break;
}
}
return 0;
}
But if I type that the vector size (x) is equal to 5 or greater, when I enter the fifth number the program finishes. Any idea how to fix the problem? I’m using Dev-C++ 5.11
For me it worked right in Code::Blocks.
– isaque