You are not logged in. Please login at www.codechef.com to post your questions!

×

[closed] cin works but getchar() doesn't while taking a char input

these are my two solutions for marblegf during december long challange.

http://www.codechef.com/viewsolution/3085218

http://www.codechef.com/viewsolution/3078607

look at both the solutions. the only difference is when i used getchar_unlocked() in taking an input for character in every test case, resulted me as a wrong answer. whereas when i changed it to cin it is accepted.

can anyone pls explain why does that happen. where does getchar() result wrong in taking a character.

asked 25 Dec '13, 13:32

vinayawsm's gravatar image

4★vinayawsm
1.9k21430
accept rate: 24%

closed 28 Dec '13, 14:17

kunal361's gravatar image

4★kunal361
6.0k133272

The question has been closed for the following reason "The question is answered, right answer was accepted" by kunal361 28 Dec '13, 14:17


i had also got that error....this soln got AC...LINK...maybe there is a space before the '\n' hence the error is generated!!!

link

answered 25 Dec '13, 15:46

kunal361's gravatar image

4★kunal361
6.0k133272
accept rate: 21%

edited 25 Dec '13, 15:48

i think @kuruma can explain if there is any such error in the test file...!!!

(25 Dec '13, 16:52) kunal3614★
1

@kunal361 ok i understood.. thank you

(28 Dec '13, 14:04) vinayawsm4★

glad could help...:)

(28 Dec '13, 14:17) kunal3614★

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,917
×1,490
×39
×19
×9
×8

question asked: 25 Dec '13, 13:32

question was seen: 1,186 times

last updated: 28 Dec '13, 14:17