|
|
back to boardwhy am I WA?(C) #include<stdio.h> #include<math.h> int main() {double a[10000]; int n; for(n=1;scanf("%lf",&a[n])!=EOF;n++); for(;n>=1;n--) {a[n]=sqrt(a[n]); printf("%0.4lf\n",a[n]); } return 0; } Re: why am I WA?(C) NO one can tall me that? what should I do? Re: why am I WA?(C) Маловато наверно будет 10000. У меня была размерность больше 100 тыщ... Re: why am I WA?(C) You should change size of your array... Re: why am I WA?(C) I think you should use stack, Re: why am I WA?(C) Posted by HJ 8 Jun 2008 20:30 Just one more semicolon(;). for(n=1;scanf("%lf",&a[n])!=EOF;n++); Re: why am I WA?(C) scanf return the number of fields successfully converted and assigned; the return value does not include fields that were read but not assigned. A return value of 0 indicates that no fields were assigned. The return value is EOF for an error or if the end-of-file character or the end-of-string character is encountered in the first attempt to read a character.according to compilor,the result of EOF can be -1.each number or character that you input from the keyboard is ASCII,so the sentence "for(n=1;scanf("%lf",&a[n])!=EOF;n++);" would never be ended. |
|
|