Page 1 of 1

Posted: Sat Mar 23, 2002 4:34 pm
by tanbetien
Would you please help me on coding C++.
First, when I tried to write a program by C++, and submitted. What I received from the Judge is that: "wrong answer"
( I used: while(!cin.eof()) {....} to allow inputs from the judge)
However, when I just converted the program to C (by using #include <stdio.h> rather than #include <iostream>, and changed cin, cout to scanf, printf...), with the algorithms unchanged, the results received is "Accepted".
Could anyone help me out? Because I like to code in C++ more than in C.
Thanks very much in advance for your help
Sincerely

Posted: Sun Mar 24, 2002 2:10 am
by ram
Here is a link:

http://wwwinfo.cern.ch/asd/lhc++/RW/std ... assref.htm

There are lot of C++ tutorials online. Just search the web for specific problems.

Posted: Sun Mar 24, 2002 5:38 am
by Stefan Pochmann
You're probably going into the loop one time too often, since the previous read operation is unlikely to find EOF. See also:
http://www.cplusplus.com/ref/iostream/ios/eof.html

I never use cin.eof(). Try this: while( cin >> x ){...} (or whatever your input is...)