|
|
вернуться в форумWhat's wrong with my code? #include <stdio.h> #include <math.h> void main() { double n; while(scanf("%lf",&n) != EOF) printf("%.4lf\n",sqrt(n)); } It gets WA on the 1st test, although it should work (in theory). The problem is that I can't check whether it reads as it should just because I don't know how to put EOF symbol at the end of the input manually. Does anyone know how it should be done? Edited by author 09.07.2007 20:30 Re: What's wrong with my code? You must output answers in reverse order!Good luck! Maybe it'll help you: [code deleted] Edited by author 09.07.2007 23:32 Edited by author 09.07.2007 23:51 Edited by author 10.07.2007 00:28 Edited by author 12.07.2007 03:12 Re: What's wrong with my code? Thank you very much! How could I miss that... Probably because I'm not that good at stream handling and focused my mind on finding other ways to read/write streams in C/C++. Yet this code gets CE on submit, but it doesn't on my PC. Is it because those written here don't count? :)) Re: What's wrong with my code? I write this program on C++.Try to send it on C++ && you'll get AC.I create dynamic array & maybe in C it gets CE.Good luck! Edited by author 10.07.2007 23:59 Re: What's wrong with my code? Unfortunately I'm not that good at C++ console streams. How do I check the end of output? (cin >> a) != EOF Is that correct? Re: What's wrong with my code? You can check the end of output in such a way: while( cin >> a ) { //--your code--- } |
|
|