#include<stdio.h>#include<stdlib.h>#include<string.h>intmain(){int n, count =0;double f, sum =0;char s[9],*send,*sdot, c;scanf("%d",&n);while(n--){scanf("%8s", s);
c =ungetc(getchar(),stdin);
f =strtod(s,&send);
sdot =strchr(s,'.');if(!isspace(c)||*send
||(f>1000|| f <-1000)||(sdot && sdot - s <strlen(s)-3)){printf("ERROR: %s", s);while(!isspace(c =getchar()))putchar(c);printf(" is not a legal number\n");}else{
count++;
sum += f;}}if(count ==0)printf("The average of 0 numbers is Undefined\n");elseif(count ==1)printf("The average of 1 number is %.2lf", sum);elseprintf("The average of %d numbers is %.2lf", count, sum/count);return0;}