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
Please help me on C++ code
Moderator: Board moderators
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.
http://wwwinfo.cern.ch/asd/lhc++/RW/std ... assref.htm
There are lot of C++ tutorials online. Just search the web for specific problems.
-
- A great helper
- Posts: 284
- Joined: Thu Feb 28, 2002 2:00 am
- Location: Germany
- Contact:
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...)
http://www.cplusplus.com/ref/iostream/ios/eof.html
I never use cin.eof(). Try this: while( cin >> x ){...} (or whatever your input is...)