-1
Good evening, I wonder if in this program I am using the EOF(end of file) right, IE, while I do not type 0, the vector will be allocated and recorded with a value?? Follows code below:
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
int i,j, counter = 1,mediaaritmetica, novasequencia;
int* sequencia = NULL;
while (scanf(%d), &sequencia[i] != EOF)
{
sequencia = (int*) realloc(sequencia, counter * sizeof(int));
scanf("%d", &sequencia[i]);
counter++
}
for (j = 0; j < counter ; j++)
{
mediaartimetica += sequencia[j];
}
mediaaritmetica = mediaartimetica/counter - 1;
for ( k = 2, k < counter ; k++)
{
novasequencia = pow(sequencia[k], 2)/mediaaritmetica * (sequencia[k - 2] + sequencia[k -1] + sequencia[k])
printf(".4%d\n", novasequencia);
}
return 0;
}
The code you have presented does not even compile yet. I think there is scope for you to hit a lot before attacking the EOF problem. :)
– hugomg