Read N numbers in a vector, and calculate the repetitions

0

Hello, I need help with an issue, the statement asks

Read a sequence of n real numbers in a vector, calculate the quantity and percentage of times that each of the numbers repeats. the number 'n' of numbers should also be read from the keyboard and the result should be stored in vectors and printed at the end, together with the input vector

What has been done so far has been

int main() {
 int n,               /* numero de elementos da sequencia  */
  i, j,                 
  comp,              /* comprimento corrente do vetor seq */
  conta, vezes;
 float seq[MAX];

  printf("Digite o quantidade n de numeros que sera lido: ");
  scanf("%d",&n);


 printf("\nDigite o numero %d: ", n);
 for (i = 0; i < n; i++)

  scanf("%f", &seq[i]);
 for (i = 0; i < n; i++) {
 /* conta o numero de vezes que seq[i] aparece no vetor a partir da posi鈬o i */
 vezes = 1;
 j = i + 1;
 while (j < n)
   if (seq[j] != seq[i]) 
 j++; 
   else {
     vezes++;
 /* quando repete, remove */
     n--;                   
     seq[j] = seq[n];       
   }
 printf("%f ocorre %d vezes\n", seq[i], vezes);
}

return 0;
}

Obviously it's wrong, but I'm stuck, I do not know what else to do. I apologize for any errors, it's my first time using the site.

    
asked by anonymous 18.06.2018 / 18:38

0 answers