Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
0Activity
0 of .
Results for:
No results containing your search query
P. 1
Count Intersections

Count Intersections

Ratings: (0)|Views: 4|Likes:
Published by Abhik Mitra

More info:

Published by: Abhik Mitra on Jun 25, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

06/25/2012

pdf

text

original

 
 
Confidential
Count Intersections
There's a line from (x1,y1) to (x2,y2) in a grid of squares of unit length. Write a program tocompute the number of squares which are intersected by the line internally, i.e squares which areonly touched by the line should not be counted.
Notes
x1,y1,x2,y2 are all integers.
0 <= x1,y1,x2,y2 <= 10000
Write the program so that it accepts 4 command line parameters - x1,y1,x2,y2
The output of the program should be a single line consisting of only the integer outputvalue.
Examples
1)
 Input (x1 y1 x2 y2):
 
1 1 6 6
 
Output (No. of squares):
 
5
 2)
 Input:
 
1 1 7 6
 
Output:
 
10
 

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->