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

×

Reading character and converting to integer

In many solutions I see people reading in character in place of integer and then converting the character to integer. What effect does it have on time and memory. What is the main idea behind doing this? Can someone explain this with a good example. Thank You!

asked 02 Aug '13, 02:10

devil_coder's gravatar image

2★devil_coder
30125
accept rate: 0%


basically it is done to reduce the time of execution...see these two codes for the problem INTEST!!!

CODE1 using scanf, time:- 5.54 secs.

CODE2 using char by char input and output, time:- 0.82 secs

for understanding this method u can refer to this post....LINK..on this link getc() is used...a faster method is to use getchar_unlocked() in place of getc()....hope this helps..:)

link

answered 02 Aug '13, 08:26

kunal361's gravatar image

4★kunal361
6.0k133272
accept rate: 21%

edited 02 Aug '13, 08:44

toggle preview
Preview

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,465
×243
×191
×105

question asked: 02 Aug '13, 02:10

question was seen: 806 times

last updated: 02 Aug '13, 08:44