And I don't know why!!

Please, anyone can help me?

Code: Select all

```
#include <stdio.h>
#define MAX(A, B) ( (A) > (B) ? (A) : (B) )
int main()
{
int i, estudantes, media, troca, trocaMenor, trocaMaior, vetor[1005];
double total, valor, aux, mediaAux;
while ( scanf( "%d", &estudantes ) == 1 && estudantes )
{
total = 0.0;
for ( i = 0; i < estudantes; i++ )
{
scanf( "%lf", &valor );
total += valor;
aux = 1000 * valor;
vetor[i] = (int) (aux/10);
}
mediaAux = total/estudantes;
media = 1000 * mediaAux;
media = (int) (media/10);
trocaMenor = trocaMaior = 0;
for ( i = 0; i < estudantes; i++ )
{
if ( vetor[i] < media )
trocaMenor += media - vetor[i];
else
if ( vetor[i] > media + 1)
trocaMaior += vetor[i] - media - 1;
}
troca = MAX(trocaMenor, trocaMaior);
valor = (double) troca / 100.0;
printf("$%.2lf\n", valor);
}
return 0;
}
```