Please help me on C++ code

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
tanbetien
New poster
Posts: 3
Joined: Fri Mar 22, 2002 2:00 am
Location: Singapore
Contact:

Post 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
ram
New poster
Posts: 30
Joined: Wed Mar 06, 2002 2:00 am
Contact:

Post 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.
Stefan Pochmann
A great helper
Posts: 284
Joined: Thu Feb 28, 2002 2:00 am
Location: Germany
Contact:

Post 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...)
Post Reply

Return to “C++”