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


Online IDE's input vs local input problem


I participated in the October Cook Off and came up with the correct solution to the third problem, My solution: . It gives wrong answer on online judges but run perfectly fine on my machine.
If I make a small change. Replacing scanf by cin then the judge identifies the solution as correct as can be seen in this submission:
In original :-
scanf("%d", &T);
cin >> str;
In modified:-
cin >> T;
cin >> str;
What things can I do to avoid this in the future ? (Should I not mix and match scanf/printf with cin/cout ?) Aren't online judges at fault here ? ( ideone and Codechef both are giving incorrect results here)

asked 25 Oct '17, 23:23

ellipse0934's gravatar image

accept rate: 0%

edited 25 Oct '17, 23:25

When replacing scanf fixes the error then this obvious that the issue is somewhere in the input-output aprt of your code, and it indeed is.

Let me ask, why are you using this-


Have you understood its function and working? Look bro, not knowing things about your language will always cost you somewhere or other, so dont ignore this part.

When you use these 2 lines, then you should either use scanf/printf throughout or cin/cout throughout, else it will malfunction.

Read about it here :


answered 26 Oct '17, 00:12

vijju123's gravatar image

5★vijju123 ♦♦
accept rate: 18%

edited 26 Oct '17, 00:15

toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 25 Oct '17, 23:23

question was seen: 188 times

last updated: 26 Oct '17, 00:15