tag:blogger.com,1999:blog-42767154257871719512024-03-14T09:54:36.275+05:30rrc.devrooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.comBlogger31125tag:blogger.com,1999:blog-4276715425787171951.post-61568262877495881082011-03-15T13:17:00.001+05:302011-03-19T06:59:42.518+05:30Wee Willy Widget Shop ( Discrete Event System Simulation )<div dir="ltr" style="text-align: left;" trbidi="on">
<b style="color: red; font-family: Times, 'Times New Roman', serif; font-size: x-large;">Problem: </b><span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif;">The Wee Willy Widget Shop overhauls and repair all types of widgets. The shop consists of five work stations, and the flow of jobs through the shop is as depicted here:</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://lh3.googleusercontent.com/-wW_8NnR5Olo/TX8UYLBzKkI/AAAAAAAAASo/9beMg3qb9Qc/s1600/ModSim01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="332" src="https://lh3.googleusercontent.com/-wW_8NnR5Olo/TX8UYLBzKkI/AAAAAAAAASo/9beMg3qb9Qc/s640/ModSim01.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif;">Regular jobs arrive at station A at the rate of one every 15 </span><span class="Apple-style-span" style="line-height: 15px;"><span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif;">± 13 minutes. Rush jobs arrive every 4 </span></span><span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif; line-height: 15px;">± 3 hours and are given a higher priority except at station C, where they are put on a conveyor and sent through a cleaning and degreasing operation along with all other jobs. For jobs the first time through a station, processing and repair times are as follows:</span><br />
<span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif; line-height: 15px;"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://lh3.googleusercontent.com/-7WSuS-VKVqA/TX8V0dPyMBI/AAAAAAAAASs/F29sHWQR9zw/s1600/ModSim02.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="254" src="https://lh3.googleusercontent.com/-7WSuS-VKVqA/TX8V0dPyMBI/AAAAAAAAASs/F29sHWQR9zw/s640/ModSim02.png" width="640" /></a></div>
<span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif;"><span class="Apple-style-span" style="line-height: 15px;"><br /></span></span><br />
<span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif;"><span class="Apple-style-span" style="line-height: 15px;">The times listed above hold for all jobs that follow one of the two sequences A </span></span><span class="Apple-style-span" style="line-height: 15px;"><span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif;">→ B </span></span><span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif; line-height: 15px;">→ C </span><span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif; line-height: 15px;">→ D </span><span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif; line-height: 15px;">→ E or A </span><span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif; line-height: 15px;">→ B </span><span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif; line-height: 15px;">→ D </span><span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif; line-height: 15px;">→ E. However, about 10% of the jobs coming out of station D are sent back to B for further work (which takes 30 </span><span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif; line-height: 15px;">±</span><span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif; line-height: 15px;"> 10 minutes) and then are sent to D and finally to E.</span><br />
<span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif; line-height: 15px;">Every 2 hours, beginning 1 hour after opening, the degreasing station C shuts down for routine maintenance, which takes 10 </span><span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif; line-height: 15px;">± 1 minute. However, this routine maintenance does not begin until the current widget, if any, has completed its processing.</span><br />
<span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif; line-height: 15px;"><b>(a)</b> Make three independent replications of the simulation model, where one replication equals an 8-hour simulation run, preceded by a 2-hour initialization run. The three sets of output represent three typical days. The main performance measure of interest is mean response time per job, where a response time is the total time a job spends in the shop. The shop is never empty in the morning, but the model will be empty without the initialization phase. So run the model for a 2-hour initialization period and collect statistics from time 2 hours to time 10 hours. This "warm-up" period will reduce the downward bias in the estimate of mean response time. Note that the 2-hour warm-up is a device to load a simulation model to some more realistic level than empty. From each of the three independent replications, obtain an estimate of mean response time. Also obtain an overall estimate, the sample average of the three estimates.</span><br />
<span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif; line-height: 15px;"><b>(b)</b> Management is considering putting one additional worker at the busiest station (A, B, D, or E). Would this significantly improve mean response time?</span><br />
<span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif; line-height: 15px;"><b>(c) </b>As an alternative to part (b), management is considering replacing machine C with a faster one that processes a widget in only 14 minutes. Would this significantly improve mean response time?</span><br />
<span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif; line-height: 15px;"><br /></span><br />
<span class="Apple-style-span" style="line-height: 15px;"><b style="color: #6aa84f; font-family: Times, 'Times New Roman', serif; font-size: x-large;">Solution: </b><span class="Apple-style-span" style="color: blue; font-family: Georgia, 'Times New Roman', serif;">Code is written in C++ and there is also a pdf file containing the analysis for all three parts of this problem. It is available <a href="http://bazaar.launchpad.net/~just-4-u-7191/+junk/Code/files/head:/MAS_Assign01/">here</a>.</span></span></div>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com6tag:blogger.com,1999:blog-4276715425787171951.post-14449339494076904212011-03-15T10:44:00.004+05:302011-03-19T06:56:22.063+05:30Catenary - shape of a chain hanging from two points<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span class="Apple-style-span" style="color: #cc0000; font-family: Times, 'Times New Roman', serif;">Problem:</span></b> <span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif;">Given a chain (string) or length L and it is hanged somewhere by fixed its both endpoints, but the euclidean distance between endpoints in 3D is less than L. And the chain have <span class="Apple-style-span" style="line-height: 15px;">μ mass per unit length. Determine the shape of the resulting curve.</span></span><br />
<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: x-small; line-height: 15px;"><br /></span><br />
<span class="Apple-style-span" style="line-height: 15px;"><span class="Apple-style-span" style="color: #6aa84f; font-family: Times, 'Times New Roman', serif;"><b>Commentary:</b></span> </span><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif; line-height: 15px;">Shape formed is known as Catenary in literature. Solution of this problem is precisely the shape of garlands hanging in weddings or temples. Mathematical treatment of this problem leads to some very interesting insight into the physical characteristics of these types of curves.</span><br />
<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: x-small; line-height: 15px;"><br /></span><br />
<span class="Apple-style-span" style="line-height: 15px;"><span class="Apple-style-span" style="color: #6aa84f; font-family: Times, 'Times New Roman', serif;"><b>Analysis:</b></span> </span><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"><span class="Apple-style-span" style="line-height: 15px;">A nearly complete analysis of this problem is given at </span><a href="http://en.wikipedia.org/wiki/Catenary#Alternative_analysis">http://en.wikipedia.org/wiki/Catenary#Alternative_analysis</a></span><br />
<br />
<span class="Apple-style-span" style="color: #6aa84f; font-family: Times, 'Times New Roman', serif;"><b>Coding:</b></span> <span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">Even though the equations are given on wikipedia page, it is unclear how to code to get the shape of curve given two endpoints and length of the string. But this problem was thoroughly discussed in <a href="http://www.serc.iisc.ernet.in/~amohanty/SE289/index.html">NSDE </a>lecture 04 (12-01-2011) by <a href="http://www.serc.iisc.ernet.in/~amohanty/">Prof. Atanu Mohanty</a>. He gave some hints regarding how to implement it in C.</span><br />
<span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">If you are interested in seeing the code it is available <a href="http://bazaar.launchpad.net/~just-4-u-7191/+junk/Code/files/head:/NSDE/Demo1/01%20Catenary/">here</a>.</span><br />
<br />
<b><span class="Apple-style-span" style="color: #6aa84f; font-family: Times, 'Times New Roman', serif;">Result:</span></b><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://lh5.googleusercontent.com/-5AtjpycPR5c/TX7228rjIBI/AAAAAAAAASg/TsOtEufJkuo/s1600/Catenary.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="361" src="https://lh5.googleusercontent.com/-5AtjpycPR5c/TX7228rjIBI/AAAAAAAAASg/TsOtEufJkuo/s640/Catenary.png" width="640" /></a></div>
<b><span class="Apple-style-span" style="color: #6aa84f;"><br /></span></b></div>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com1tag:blogger.com,1999:blog-4276715425787171951.post-30838616613066402972010-09-07T20:54:00.002+05:302010-09-07T20:59:53.027+05:30Plotting a basic 2D graph using C + gnuplot (Tutorial)In this tutorial we will learn how to draw a graph using ANSI C language with the help of <a href="http://www.gnuplot.info/">gnuplot</a> utility.<br />
<br />
<b><span style="color: #134f5c;">Step 1</span></b> write a c program using any editor. (here file name is plot.c)<b><span style="color: #134f5c;"> </span></b><br />
<br />
<div class="c_mac" style="background-color: #f0f0f0; border: 1px solid rgb(208, 208, 208); color: #000066; font-family: monospace;">
<span style="color: red; font-style: italic;">/*<br />
* file: plot.c<br />
*<br />
* Copyright 2010 Rooparam Choudhary <rooparam@rishi.serc.iisc.ernet.in><br />
*<br />
* Date : 07.09.2010<br />
*<br />
* This program is free software; you can redistribute it and/or modify<br />
* it under the terms of the GNU General Public License as published by<br />
* the Free Software Foundation; either version 2 of the License, or<br />
* (at your option) any later version.<br />
* <br />
* This program is distributed in the hope that it will be useful,<br />
* but WITHOUT ANY WARRANTY; without even the implied warranty of<br />
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br />
* GNU General Public License for more details.<br />
* <br />
* You should have received a copy of the GNU General Public License<br />
* along with this program; if not, write to the Free Software<br />
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,<br />
* MA 02110-1301, USA.<br />
*<br />
*/</span><br />
<br />
<span style="color: #339900;">#include <stdio.h></span><br />
<br />
<span style="color: blue;">double</span> func <span style="color: black;">(</span> <span style="color: blue;">double</span> x <span style="color: black;">)</span> <span style="color: black;">{</span><br />
<span style="color: blue;">if</span> <span style="color: black;">(</span> x < <span style="color: #0000dd;">0</span> <span style="color: black;">)</span><br />
<span style="color: blue;">return</span> <span style="color: #0000dd;">0</span> ;<br />
<span style="color: blue;">if</span> <span style="color: black;">(</span> x < <span style="color: #0000dd;">2</span> <span style="color: black;">)</span><br />
<span style="color: blue;">return</span> x <span style="color: black;">*</span> x ;<br />
<br />
<span style="color: blue;">return</span> <span style="color: purple;">16.0</span> <span style="color: black;">/</span> <span style="color: black;">(</span> x <span style="color: black;">*</span> x <span style="color: black;">)</span> ;<br />
<span style="color: black;">}</span><br />
<br />
<span style="color: red; font-style: italic;">/*<br />
* output will be in 2 coloumns<br />
* 1 column contains x-axis values<br />
* 2 column contains y-axis {or f(x) } values corresponding to x-value<br />
*/</span><br />
<span style="color: blue;">int</span> main <span style="color: black;">(</span> <span style="color: black;">)</span> <span style="color: black;">{</span><br />
<span style="color: blue;">double</span> x <span style="color: black;">=</span> <span style="color: purple;">0.0</span>; <span style="color: red;">// initial value</span><br />
<span style="color: blue;">double</span> x_max <span style="color: black;">=</span> <span style="color: purple;">5.0</span>;<br />
<span style="color: blue;">double</span> step <span style="color: black;">=</span> <span style="color: purple;">0.01</span>;<br />
<br />
<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html" style="color: #000060;"><span style="color: #0000dd;">printf</span></a> <span style="color: black;">(</span> <span style="color: #666666;">"# x <span style="color: #000099; font-weight: bold;">\t</span> f(x) <span style="color: #000099; font-weight: bold;">\n</span>"</span> <span style="color: black;">)</span>;<br />
<br />
<span style="color: blue;">while</span> <span style="color: black;">(</span> x <<span style="color: black;">=</span> x_max <span style="color: black;">)</span> <span style="color: black;">{</span><br />
<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html" style="color: #000060;"><span style="color: #0000dd;">printf</span></a> <span style="color: black;">(</span> <span style="color: #666666;">"%.3f <span style="color: #000099; font-weight: bold;">\t</span> %.3f <span style="color: #000099; font-weight: bold;">\n</span>"</span>, x, func<span style="color: black;">(</span>x<span style="color: black;">)</span> <span style="color: black;">)</span>;<br />
x <span style="color: black;">+=</span> step;<br />
<span style="color: black;">}</span><br />
<br />
<span style="color: blue;">return</span> <span style="color: #0000dd;">0</span>;<br />
<span style="color: black;">}</span></div>
<br />
<br />
<b><span style="color: #134f5c;">Step 2</span></b> compile it and run it and grab the output in plot.txt file<br />
<br />
$ cc plot.c<br />
$ ./a.out >plot.txt<br />
<br />
<b><span style="color: #134f5c;">Step 3</span></b> Draw using gnuplot<br />
<br />
$ gnuplot<br />
gnuplot> plot "./plot.txt" with lines<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/_4Mr9PcctaeY/TIZYQUefjGI/AAAAAAAAARM/Hh7ZJOGq6b4/s1600/plot.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="http://1.bp.blogspot.com/_4Mr9PcctaeY/TIZYQUefjGI/AAAAAAAAARM/Hh7ZJOGq6b4/s640/plot.png" width="640" /></a></div>
<br />
<br />
OK folks.<br />
Tutorial is over.<br />
<br />
This was just an introduction for plotting basic graphs. For more plotting tutorials and advanced plotting, just visit <a href="http://www.gnuplot.info/">gnuplot</a> .<br />
<br />
See ya later.rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com1tag:blogger.com,1999:blog-4276715425787171951.post-75102026263678679452010-08-27T01:18:00.001+05:302010-08-27T01:20:56.982+05:30Facts of Lagrange Interpolation<div style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;">"Lagrangian interpolation is praised for analytic utility and beauty but deplored for numerical practice." This heading, from the extended table of contents of one of the most enjoyable textbooks of numerical analysis [1],expresses a widespread view. </span> </div>
<div style="font-family: Georgia,"Times New Roman",serif;">
<br /></div>
<div style="font-family: Georgia,"Times New Roman",serif;">
[...] Given (<i>x0, f0</i>), (<i>x1, f1</i>), . . ., (<i>xn, fn</i>) with arbitrary spaced <i>xj</i>, Lagrange had the idea of multiplying each <i>fj</i> by a polynomial that is 1 at <i>xj</i> and 0 at the other <i>n</i> nodes and then taking the sum of these <i>n + 1</i> polynomials. Clearly, this gives the unique interpolation polynomial of degree <i>n</i> or less. [...]</div>
<div style="font-family: Georgia,"Times New Roman",serif;">
( Erwin Kreyszig, <i>Advanced Engineering Mathematics</i> ) </div>
<div style="font-family: Georgia,"Times New Roman",serif;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/_4Mr9PcctaeY/THbCE8jOhQI/AAAAAAAAAQ8/I211bdwxPzA/s1600/lagrange_interpolation.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="256" src="http://2.bp.blogspot.com/_4Mr9PcctaeY/THbCE8jOhQI/AAAAAAAAAQ8/I211bdwxPzA/s640/lagrange_interpolation.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figure : Lagrange Interpolation of function 1/(1+x*x)</td></tr>
</tbody></table>
<div style="font-family: Georgia,"Times New Roman",serif;">
<br /></div>
<div style="font-family: Georgia,"Times New Roman",serif;">
<br /></div>
<div style="font-family: Georgia,"Times New Roman",serif;">
[...] Lagrange and other interpolation at equally spaced points, as in the
example above, yield a polynomial oscillating above and below the true
function. This behaviour tends to grow with the number of points,
leading to a divergence known as <a href="http://en.wikipedia.org/wiki/Runge%27s_phenomenon" title="Runge's phenomenon">Runge's phenomenon</a>; the problem may be eliminated by choosing interpolation points at <a href="http://en.wikipedia.org/wiki/Chebyshev_nodes" title="Chebyshev nodes">Chebyshev nodes</a>. [...]</div>
<div style="font-family: Georgia,"Times New Roman",serif;">
( <a href="http://en.wikipedia.org/wiki/Lagrange_interpolation">Wikipedia</a> )</div>
<div style="font-family: Georgia,"Times New Roman",serif;">
<br /></div>
<div style="font-family: Georgia,"Times New Roman",serif;">
Although their are superior interpolation methods than <i>lagrange interpolation</i> method. But it is quite easy to understand and it is superior than <i>Taylor Series Approximation</i> of a function. It can be seen easily by following diagram.</div>
<div style="font-family: Georgia,"Times New Roman",serif;">
Here I choose <i><b>f(x) = e^x</b></i> in the interval [0, 2]</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/_4Mr9PcctaeY/THbEFOmZ7dI/AAAAAAAAARE/i2w7X9I10j4/s1600/taylor_vs_lagrange+%28RE%29.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="http://2.bp.blogspot.com/_4Mr9PcctaeY/THbEFOmZ7dI/AAAAAAAAARE/i2w7X9I10j4/s640/taylor_vs_lagrange+%28RE%29.png" width="640" /></a></div>
<div style="font-family: Georgia,"Times New Roman",serif;">
<br /></div>
<div style="font-family: Georgia,"Times New Roman",serif;">
[1] F. S. Acton, <i>Numerical Methods That [Usually] Work</i>, AMS, Providence, RI, 1990.</div>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com0tag:blogger.com,1999:blog-4276715425787171951.post-17356980470995371162010-03-30T14:39:00.003+05:302010-03-30T14:41:36.611+05:30twitter accountjust removed 2 redundant accounts from twitter.com and now i have only 1 twitter acct and its <a href="http://twitter.com/rrc_iisc">http://twitter.com/rrc_iisc</a>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com0tag:blogger.com,1999:blog-4276715425787171951.post-12613849071599725392009-12-11T09:48:00.000+05:302009-12-11T09:48:13.005+05:30Area Filling Algorithms (seed filling, ScanLine conversion)<br />
<div class="cpp" style="background-color: #f0f0f0; border-bottom: #d0d0d0 1px solid; border-left: #d0d0d0 1px solid; border-right: #d0d0d0 1px solid; border-top: #d0d0d0 1px solid; color: #000066; font-family: monospace;">
<ol>
<li style="color: #003030; font: 130% 'Courier New', Courier, monospace; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: #339900; font-size: small;">#include <graphics.h></span><br />
</div>
<span style="font-size: small;"></span><br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: #339900;">#include <iostream></span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: #339900;">#define ROUND(x) ((int)(x+0.5))</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">typedef</span> <span style="color: blue;">int</span> Point<span style="color: green;">[</span>2<span style="color: green;">]</span><span style="color: teal;">;</span> <span style="color: #666666;">// P[0] - x coordinate P[1] - y coordinate</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">void</span> seedFill<span style="color: green;">(</span><span style="color: blue;">int</span> x, <span style="color: blue;">int</span> y, <span style="color: blue;">int</span> color<span style="color: green;">)</span> <span style="color: green;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">if</span><span style="color: green;">(</span>x <span style="color: navy;">></span> 640 <span style="color: #000040;">||</span> x <span style="color: navy;"><</span> 0 <span style="color: #000040;">||</span> y <span style="color: navy;">></span> 480 <span style="color: #000040;">||</span> y <span style="color: navy;"><</span> 0<span style="color: green;">)</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">return</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">if</span><span style="color: green;">(</span>getpixel<span style="color: green;">(</span>x, y<span style="color: green;">)</span> <span style="color: navy;">==</span> BLACK<span style="color: green;">)</span> <span style="color: green;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
putpixel<span style="color: green;">(</span>x, y, color<span style="color: green;">)</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
seedFill<span style="color: green;">(</span>x<span style="color: #000040;">+</span>1, y, color<span style="color: green;">)</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
seedFill<span style="color: green;">(</span>x<span style="color: #000040;">-</span>1, y, color<span style="color: green;">)</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
seedFill<span style="color: green;">(</span>x, y<span style="color: #000040;">+</span>1, color<span style="color: green;">)</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
seedFill<span style="color: green;">(</span>x, y<span style="color: #000040;">-</span>1, color<span style="color: green;">)</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: green;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: green;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">void</span> scanlineFill<span style="color: green;">(</span>Point <span style="color: #000040;">*</span>polygon, <span style="color: blue;">int</span> nodes, <span style="color: blue;">int</span> color<span style="color: green;">)</span> <span style="color: green;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
setcolor<span style="color: green;">(</span>color<span style="color: green;">)</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
Point array<span style="color: green;">[</span>480<span style="color: green;">]</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">for</span><span style="color: green;">(</span><span style="color: blue;">int</span> i<span style="color: navy;">=</span><span style="color: #0000dd;">0</span><span style="color: teal;">;</span> i<span style="color: navy;"><</span><span style="color: #0000dd;">480</span><span style="color: teal;">;</span> <span style="color: #000040;">++</span>i<span style="color: green;">)</span> <span style="color: green;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
array<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: navy;">=</span> <span style="color: #0000dd;">640</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
array<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>1<span style="color: green;">]</span> <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: green;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">for</span><span style="color: green;">(</span><span style="color: blue;">int</span> i<span style="color: navy;">=</span><span style="color: #0000dd;">0</span><span style="color: teal;">;</span> i<span style="color: navy;"><</span>nodes<span style="color: teal;">;</span> <span style="color: #000040;">++</span>i<span style="color: green;">)</span><span style="color: green;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
Point p1, p2<span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
p1<span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: navy;">=</span> polygon<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>0<span style="color: green;">]</span><span style="color: teal;">;</span> p1<span style="color: green;">[</span>1<span style="color: green;">]</span> <span style="color: navy;">=</span> polygon<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
p2<span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: navy;">=</span> polygon<span style="color: green;">[</span><span style="color: green;">(</span>i<span style="color: #000040;">+</span>1<span style="color: green;">)</span><span style="color: #000040;">%</span>nodes<span style="color: green;">]</span><span style="color: green;">[</span>0<span style="color: green;">]</span><span style="color: teal;">;</span> p2<span style="color: green;">[</span>1<span style="color: green;">]</span> <span style="color: navy;">=</span> polygon<span style="color: green;">[</span><span style="color: green;">(</span>i<span style="color: #000040;">+</span>1<span style="color: green;">)</span><span style="color: #000040;">%</span>nodes<span style="color: green;">]</span><span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">if</span><span style="color: green;">(</span>p1<span style="color: green;">[</span>1<span style="color: green;">]</span> <span style="color: navy;">></span> p2<span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: green;">)</span> <span style="color: green;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
p2<span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: navy;">=</span> polygon<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>0<span style="color: green;">]</span><span style="color: teal;">;</span> p2<span style="color: green;">[</span>1<span style="color: green;">]</span> <span style="color: navy;">=</span> polygon<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
p1<span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: navy;">=</span> polygon<span style="color: green;">[</span><span style="color: green;">(</span>i<span style="color: #000040;">+</span>1<span style="color: green;">)</span><span style="color: #000040;">%</span>nodes<span style="color: green;">]</span><span style="color: green;">[</span>0<span style="color: green;">]</span><span style="color: teal;">;</span> p1<span style="color: green;">[</span>1<span style="color: green;">]</span> <span style="color: navy;">=</span> polygon<span style="color: green;">[</span><span style="color: green;">(</span>i<span style="color: #000040;">+</span>1<span style="color: green;">)</span><span style="color: #000040;">%</span>nodes<span style="color: green;">]</span><span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: green;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">double</span> m <span style="color: navy;">=</span> <span style="color: green;">(</span><span style="color: blue;">double</span><span style="color: green;">)</span><span style="color: green;">(</span>p2<span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: #000040;">-</span>p1<span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: green;">)</span><span style="color: #000040;">/</span><span style="color: green;">(</span>p2<span style="color: green;">[</span>0<span style="color: green;">]</span><span style="color: #000040;">-</span>p1<span style="color: green;">[</span>0<span style="color: green;">]</span><span style="color: green;">)</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">double</span> xd <span style="color: navy;">=</span> p1<span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: #000040;">-</span> 1<span style="color: #000040;">/</span>m<span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">for</span><span style="color: green;">(</span><span style="color: blue;">int</span> y<span style="color: navy;">=</span>p1<span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: teal;">;</span> y<span style="color: navy;"><=</span>p2<span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: teal;">;</span> <span style="color: #000040;">++</span>y<span style="color: green;">)</span> <span style="color: green;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
xd <span style="color: #000040;">+</span><span style="color: navy;">=</span> 1<span style="color: #000040;">/</span>m<span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">int</span> x <span style="color: navy;">=</span> ROUND<span style="color: green;">(</span>xd<span style="color: green;">)</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">if</span><span style="color: green;">(</span>array<span style="color: green;">[</span>y<span style="color: green;">]</span><span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: navy;">></span> x<span style="color: green;">)</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
array<span style="color: green;">[</span>y<span style="color: green;">]</span><span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: navy;">=</span> x<span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">if</span><span style="color: green;">(</span>array<span style="color: green;">[</span>y<span style="color: green;">]</span><span style="color: green;">[</span>1<span style="color: green;">]</span> <span style="color: navy;"><</span> x<span style="color: green;">)</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
array<span style="color: green;">[</span>y<span style="color: green;">]</span><span style="color: green;">[</span>1<span style="color: green;">]</span> <span style="color: navy;">=</span> x<span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: green;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: green;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">for</span><span style="color: green;">(</span><span style="color: blue;">int</span> i<span style="color: navy;">=</span><span style="color: #0000dd;">0</span><span style="color: teal;">;</span> i<span style="color: navy;"><</span><span style="color: #0000dd;">480</span><span style="color: teal;">;</span> <span style="color: #000040;">++</span>i<span style="color: green;">)</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">if</span><span style="color: green;">(</span>array<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: navy;"><</span> array<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: green;">)</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
line<span style="color: green;">(</span>array<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>0<span style="color: green;">]</span><span style="color: #000040;">+</span>1, i, array<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: #000040;">-</span>1, i<span style="color: green;">)</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: green;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">void</span> drawPolygon<span style="color: green;">(</span>Point <span style="color: #000040;">*</span>polygon, <span style="color: blue;">int</span> nodes<span style="color: green;">)</span> <span style="color: green;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
setcolor<span style="color: green;">(</span>WHITE<span style="color: green;">)</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">for</span><span style="color: green;">(</span><span style="color: blue;">int</span> i<span style="color: navy;">=</span><span style="color: #0000dd;">0</span><span style="color: teal;">;</span> i<span style="color: navy;"><</span>nodes<span style="color: teal;">;</span> <span style="color: #000040;">++</span>i<span style="color: green;">)</span><span style="color: green;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
Point p1, p2<span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
p1<span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: navy;">=</span> polygon<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>0<span style="color: green;">]</span><span style="color: teal;">;</span> p1<span style="color: green;">[</span>1<span style="color: green;">]</span> <span style="color: navy;">=</span> polygon<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
p2<span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: navy;">=</span> polygon<span style="color: green;">[</span><span style="color: green;">(</span>i<span style="color: #000040;">+</span>1<span style="color: green;">)</span><span style="color: #000040;">%</span>nodes<span style="color: green;">]</span><span style="color: green;">[</span>0<span style="color: green;">]</span><span style="color: teal;">;</span> p2<span style="color: green;">[</span>1<span style="color: green;">]</span> <span style="color: navy;">=</span> polygon<span style="color: green;">[</span><span style="color: green;">(</span>i<span style="color: #000040;">+</span>1<span style="color: green;">)</span><span style="color: #000040;">%</span>nodes<span style="color: green;">]</span><span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
line<span style="color: green;">(</span>p1<span style="color: green;">[</span>0<span style="color: green;">]</span>, p1<span style="color: green;">[</span>1<span style="color: green;">]</span>, p2<span style="color: green;">[</span>0<span style="color: green;">]</span>, p2<span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: green;">)</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: green;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: green;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">int</span> main<span style="color: green;">(</span><span style="color: green;">)</span><span style="color: green;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">int</span> gd <span style="color: navy;">=</span> DETECT, gm<span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
initgraph<span style="color: green;">(</span><span style="color: #000040;">&</span>gd, <span style="color: #000040;">&</span>gm, <span style="color: red;">"C:<span style="color: #000099; font-weight: bold;">\\</span>"</span><span style="color: green;">)</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
Point polygon<span style="color: green;">[</span>20<span style="color: green;">]</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">int</span> size <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">while</span><span style="color: green;">(</span><span style="color: blue;">true</span><span style="color: green;">)</span> <span style="color: green;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
std<span style="color: teal;">::</span><span style="color: #0000dd;">system</span><span style="color: green;">(</span><span style="color: red;">"cls"</span><span style="color: green;">)</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
std<span style="color: teal;">::</span><span style="color: #0000dd;">cout</span> <span style="color: navy;"><<</span> <span style="color: red;">"Enter size of polygon : (-1 for exit) : "</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
std<span style="color: teal;">::</span><span style="color: #0000dd;">cin</span> <span style="color: navy;">>></span> size<span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">if</span><span style="color: green;">(</span>size <span style="color: navy;">==</span> <span style="color: #000040;">-</span>1<span style="color: green;">)</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">return</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">if</span><span style="color: green;">(</span>size <span style="color: navy;">></span> 20<span style="color: green;">)</span><span style="color: green;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
std<span style="color: teal;">::</span><span style="color: #0000dd;">cout</span> <span style="color: navy;"><<</span> <span style="color: red;">"Enter size less than 20"</span> <span style="color: navy;"><<</span> std<span style="color: teal;">::</span><span style="color: #007788;">endl</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">continue</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: green;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">for</span><span style="color: green;">(</span><span style="color: blue;">int</span> i<span style="color: navy;">=</span><span style="color: #0000dd;">0</span><span style="color: teal;">;</span> i <span style="color: navy;"><</span> size<span style="color: teal;">;</span> <span style="color: #000040;">++</span>i<span style="color: green;">)</span> <span style="color: green;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
std<span style="color: teal;">::</span><span style="color: #0000dd;">cout</span> <span style="color: navy;"><<</span> <span style="color: red;">"Enter vertex : (x y) : "</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
std<span style="color: teal;">::</span><span style="color: #0000dd;">cin</span> <span style="color: navy;">>></span> polygon<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: navy;">>></span> polygon<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: green;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
drawPolygon<span style="color: green;">(</span>polygon, size<span style="color: green;">)</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
FILL<span style="color: teal;">:</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
std<span style="color: teal;">::</span><span style="color: #0000dd;">system</span><span style="color: green;">(</span><span style="color: red;">"cls"</span><span style="color: green;">)</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
std<span style="color: teal;">::</span><span style="color: #0000dd;">cout</span> <span style="color: navy;"><<</span> <span style="color: red;">"Choose an algorithm to fill."</span> <span style="color: navy;"><<</span> std<span style="color: teal;">::</span><span style="color: #007788;">endl</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
std<span style="color: teal;">::</span><span style="color: #0000dd;">cout</span> <span style="color: navy;"><<</span> <span style="color: red;">"<span style="color: #000099; font-weight: bold;">\t</span>1. seed fill"</span> <span style="color: navy;"><<</span> std<span style="color: teal;">::</span><span style="color: #007788;">endl</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
std<span style="color: teal;">::</span><span style="color: #0000dd;">cout</span> <span style="color: navy;"><<</span> <span style="color: red;">"<span style="color: #000099; font-weight: bold;">\t</span>2. scan line fill"</span> <span style="color: navy;"><<</span> std<span style="color: teal;">::</span><span style="color: #007788;">endl</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
std<span style="color: teal;">::</span><span style="color: #0000dd;">cout</span> <span style="color: navy;"><<</span> <span style="color: red;">"choice: "</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">int</span> choice<span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
std<span style="color: teal;">::</span><span style="color: #0000dd;">cin</span> <span style="color: navy;">>></span> choice<span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">switch</span><span style="color: green;">(</span>choice<span style="color: green;">)</span> <span style="color: green;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">case</span> 1<span style="color: teal;">:</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: green;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
std<span style="color: teal;">::</span><span style="color: #0000dd;">cout</span> <span style="color: navy;"><<</span> <span style="color: red;">"Enter a point inside polygon: (x y) : "</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
Point p<span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
std<span style="color: teal;">::</span><span style="color: #0000dd;">cin</span> <span style="color: navy;">>></span> p<span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: navy;">>></span> p<span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
seedFill<span style="color: green;">(</span>p<span style="color: green;">[</span>0<span style="color: green;">]</span>, p<span style="color: green;">[</span>1<span style="color: green;">]</span>,RED<span style="color: green;">)</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">break</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: green;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">case</span> 2<span style="color: teal;">:</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
scanlineFill<span style="color: green;">(</span>polygon, size, BLUE<span style="color: green;">)</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">break</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">default</span><span style="color: teal;">:</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
std<span style="color: teal;">::</span><span style="color: #0000dd;">cout</span> <span style="color: navy;"><<</span> <span style="color: red;">"I can't interpret your choice."</span> <span style="color: navy;"><<</span> std<span style="color: teal;">::</span><span style="color: #007788;">endl</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">goto</span> FILL<span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: blue;">break</span><span style="color: teal;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: green;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: green;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font: 130% 'Courier New', Courier, monospace; vertical-align: top;"><span style="font-size: small;"></span><br />
<div style="background: none transparent scroll repeat 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<span style="color: green; font-size: small;">}</span><br />
</div>
<span style="font-size: small;"></span><br />
</li>
<li style="color: #003030; font: 130% 'Courier New', Courier, monospace; vertical-align: top;"><span style="font-size: small;"></span><br />
<div style="background: none transparent scroll repeat 0% 0%; font: 1em/1.2em monospace; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;">
<br />
</div>
<br />
</li>
</ol>
</div>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com2tag:blogger.com,1999:blog-4276715425787171951.post-47591328964003402372009-12-01T15:55:00.002+05:302009-12-04T16:39:42.699+05:30Eight Queens Solution with DFS using Backtracking (Step-by-step simulation)<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/_4Mr9PcctaeY/SxYUrDJ2yWI/AAAAAAAAAI4/TTjt6wGuWaE/s1600-h/8Q_start.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/_4Mr9PcctaeY/SxYUrDJ2yWI/AAAAAAAAAI4/TTjt6wGuWaE/s320/8Q_start.png" /></a><br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/_4Mr9PcctaeY/SxYU2yoiwOI/AAAAAAAAAJA/PEo5Pb-8aDE/s1600-h/8Q_before_finish.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://2.bp.blogspot.com/_4Mr9PcctaeY/SxYU2yoiwOI/AAAAAAAAAJA/PEo5Pb-8aDE/s320/8Q_before_finish.png" width="320" /></a><br /></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/_4Mr9PcctaeY/SxYVDhVAzMI/AAAAAAAAAJI/lxY1q5zB1Vg/s1600-h/8Q_finish.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/_4Mr9PcctaeY/SxYVDhVAzMI/AAAAAAAAAJI/lxY1q5zB1Vg/s320/8Q_finish.png" /></a><br /></div>
<span style="font-size: small;"><br /></span><br />
<div class="java" style="background-color: #f0f0f0; border: 1px solid rgb(208, 208, 208); color: #000066; font-family: monospace;">
<ol>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">package</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">eight_queen</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.awt.AWTEvent</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.awt.AlphaComposite</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.awt.BorderLayout</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.awt.Color</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.awt.Composite</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.awt.EventQueue</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.awt.Frame</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.awt.Graphics</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.awt.Graphics2D</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.awt.Image</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.awt.Toolkit</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.awt.event.ActionEvent</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.awt.event.ActionListener</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.awt.event.WindowEvent</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.lang.reflect.InvocationTargetException</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.util.Random</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.util.Scanner</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.util.concurrent.locks.Lock</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.util.concurrent.locks.ReentrantLock</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.util.logging.Level</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">java.util.logging.Logger</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">javax.swing.JButton</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">javax.swing.JFrame</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">javax.swing.JOptionPane</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">import</span><span style="font-size: small;"> </span><span style="color: #006699; font-size: small;">javax.swing.JPanel</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: green; font-size: small; font-style: italic; font-weight: bold;">/**</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: green; font-size: small; font-style: italic; font-weight: bold;"> *</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: green; font-size: small; font-style: italic; font-weight: bold;"> * @author rooparam</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: green; font-size: small; font-style: italic; font-weight: bold;"> */</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">class</span><span style="font-size: small;"> Locations </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">public</span><span style="font-size: small;"> Locations</span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> size </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> at </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">new</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="color: #009900; font-size: small;">[</span><span style="font-size: small;">size</span><span style="color: #009900; font-size: small;">]</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> top </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: #cc66cc; font-size: small;">0</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> </span><span style="color: #666666; font-size: small; font-style: italic;">// next coloumn of a queen</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">public</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> top</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">public</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="color: #009900; font-size: small;">[</span><span style="color: #009900; font-size: small;">]</span><span style="font-size: small;"> at</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">class</span><span style="font-size: small;"> MyButton </span><span style="color: black; font-size: small; font-weight: bold;">extends</span><span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Ajbutton+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">JButton</span></a> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> MyButton</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">super</span><span style="color: #009900; font-size: small;">(</span><span style="color: blue; font-size: small;">"continue"</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">class</span><span style="font-size: small;"> Board </span><span style="color: black; font-size: small; font-weight: bold;">extends</span><span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Ajpanel+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">JPanel</span></a> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> Board </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> Locations Q </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> queens </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> Q</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #666666; font-size: small; font-style: italic;">//setSize(640, 480);</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> setBackground</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Acolor+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Color</span></a>.</span><span style="color: #006633; font-size: small;">WHITE</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> @Override</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">public</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">void</span><span style="font-size: small;"> paint </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Agraphics+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Graphics</span></a> g </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Aimage+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Image</span></a> image </span><span style="color: #339933; font-size: small;">=</span> <span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Atoolkit+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Toolkit</span></a>.</span><span style="color: #006633; font-size: small;">getDefaultToolkit</span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">getImage</span><span style="color: #009900; font-size: small;">(</span><span style="color: blue; font-size: small;">"eight_queen/smvdu_logo_1.gif"</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">drawImage</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">image, 0, 0, getBounds</span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">width</span><span style="font-size: small;">, getBounds</span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">height</span><span style="font-size: small;">, </span><span style="color: black; font-size: small; font-weight: bold;">this</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> drawBoard </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> g </span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> drawQueens</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">g</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> drawRemaining</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">g</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">setColor</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Acolor+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Color</span></a>.</span><span style="color: #006633; font-size: small;">RED</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Astring+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">String</span></a> str </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: blue; font-size: small;">"Coder : Rooparam Chaudhary"</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">drawString</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">str, getBounds</span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">width</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">-</span><span style="font-size: small;"> 180, getBounds</span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">height</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">-</span><span style="font-size: small;"> 10</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">private</span><span style="font-size: small;"> Locations queens</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">private</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">void</span><span style="font-size: small;"> drawRemaining</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Agraphics+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Graphics</span></a> g2</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Agraphics2d+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Graphics2D</span></a> g </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Agraphics2d+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Graphics2D</span></a></span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">g2</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> rule </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Aalphacomposite+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">AlphaComposite</span></a>.</span><span style="color: #006633; font-size: small;">SRC_OVER</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">float</span><span style="font-size: small;"> alpha </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> 0.8f</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Acomposite+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Composite</span></a> oldC </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">getComposite</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">setComposite</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Aalphacomposite+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">AlphaComposite</span></a>.</span><span style="color: #006633; font-size: small;">getInstance</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">rule, alpha</span><span style="color: #009900; font-size: small;">)</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">setPaint</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Acolor+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Color</span></a>.</span><span style="color: #006633; font-size: small;">BLACK</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> width </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> getBounds</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">width</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> height </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> getBounds</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">height</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> w_Q </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> width </span><span style="color: #339933; font-size: small;">/</span><span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">at</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">length</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> h_Q </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> height </span><span style="color: #339933; font-size: small;">/</span><span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">at</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">length</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">for</span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> col </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">top</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> col </span><span style="color: #339933; font-size: small;"><</span><span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">at</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">length</span><span style="color: #339933; font-size: small;">;</span> <span style="color: #339933; font-size: small;">++</span><span style="font-size: small;">col</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">for</span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> row </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: #cc66cc; font-size: small;">0</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> row </span><span style="color: #339933; font-size: small;"><</span><span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">at</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">length</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">++</span><span style="font-size: small;">row</span><span style="color: #009900; font-size: small;">)</span> <span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">if</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">!</span><span style="font-size: small;">Main.</span><span style="color: #006633; font-size: small;">isSafe</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">queens, row, col</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">fill3DRect</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">col</span><span style="color: #339933; font-size: small;">*</span><span style="font-size: small;">w_Q, row</span><span style="color: #339933; font-size: small;">*</span><span style="font-size: small;">h_Q, w_Q, h_Q, </span><span style="color: #000066; font-size: small; font-weight: bold;">true</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">setComposite</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">oldC</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">private</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">void</span><span style="font-size: small;"> drawQueens</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Agraphics+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Graphics</span></a> g</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> width </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> getBounds</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">width</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> height </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> getBounds</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">height</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> w_Q </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> width </span><span style="color: #339933; font-size: small;">/</span><span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">at</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">length</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> h_Q </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> height </span><span style="color: #339933; font-size: small;">/</span><span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">at</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">length</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">for</span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> col </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: #cc66cc; font-size: small;">0</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> col </span><span style="color: #339933; font-size: small;"><</span><span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">top</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">++</span><span style="font-size: small;">col</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> drawQueen</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">g, col</span><span style="color: #339933; font-size: small;">*</span><span style="font-size: small;">w_Q, queens.</span><span style="color: #006633; font-size: small;">at</span><span style="color: #009900; font-size: small;">[</span><span style="font-size: small;">col</span><span style="color: #009900; font-size: small;">]</span><span style="color: #339933; font-size: small;">*</span><span style="font-size: small;">h_Q, w_Q, h_Q</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">private</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">void</span><span style="font-size: small;"> drawBoard</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Agraphics+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Graphics</span></a> g2</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Agraphics2d+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Graphics2D</span></a> g </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Agraphics2d+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Graphics2D</span></a></span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">g2</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> rule </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Aalphacomposite+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">AlphaComposite</span></a>.</span><span style="color: #006633; font-size: small;">SRC_OVER</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">float</span><span style="font-size: small;"> alpha </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> 0.9f</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Acomposite+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Composite</span></a> oldC </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">getComposite</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">setComposite</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Aalphacomposite+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">AlphaComposite</span></a>.</span><span style="color: #006633; font-size: small;">getInstance</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">rule, alpha</span><span style="color: #009900; font-size: small;">)</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">setPaint</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Acolor+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Color</span></a>.</span><span style="color: #006633; font-size: small;">WHITE</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> width </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> getBounds</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">width</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> height </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> getBounds</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">height</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> w_Q </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> width </span><span style="color: #339933; font-size: small;">/</span><span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">at</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">length</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> h_Q </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> height </span><span style="color: #339933; font-size: small;">/</span><span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">at</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">length</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">for</span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> col </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: #cc66cc; font-size: small;">0</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> col </span><span style="color: #339933; font-size: small;"><</span><span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">at</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">length</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">++</span><span style="font-size: small;">col</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">for</span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> row </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: #cc66cc; font-size: small;">0</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> row </span><span style="color: #339933; font-size: small;"><</span><span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">at</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">length</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">++</span><span style="font-size: small;">row</span><span style="color: #009900; font-size: small;">)</span> <span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #666666; font-size: small; font-style: italic;">//g.fillRect(col*w_Q, row*h_Q, w_Q, h_Q);</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">fill3DRect</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">col</span><span style="color: #339933; font-size: small;">*</span><span style="font-size: small;">w_Q, row</span><span style="color: #339933; font-size: small;">*</span><span style="font-size: small;">h_Q, w_Q, h_Q, </span><span style="color: #000066; font-size: small; font-weight: bold;">true</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> togglePen</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">g, <a href="http://www.google.com/search?hl=en&q=allinurl%3Acolor+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Color</span></a>.</span><span style="color: #006633; font-size: small;">ORANGE</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> togglePen</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">g, <a href="http://www.google.com/search?hl=en&q=allinurl%3Acolor+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Color</span></a>.</span><span style="color: #006633; font-size: small;">ORANGE</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">setComposite</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">oldC</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">private</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">void</span><span style="font-size: small;"> togglePen</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Agraphics+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Graphics</span></a> g, <a href="http://www.google.com/search?hl=en&q=allinurl%3Acolor+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Color</span></a> clr</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">if</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">getColor</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">==</span><span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Acolor+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Color</span></a>.</span><span style="color: #006633; font-size: small;">WHITE</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">setColor</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">clr</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">else</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">setColor</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Acolor+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Color</span></a>.</span><span style="color: #006633; font-size: small;">WHITE</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">private</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">void</span><span style="font-size: small;"> drawQueen</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Agraphics+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Graphics</span></a> g, </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> x, </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> y, </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span> width, <span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> height</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Acolor+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Color</span></a> oldPen </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">getColor</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">setColor</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Acolor+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Color</span></a>.</span><span style="color: #006633; font-size: small;">BLUE</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">fillArc</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> x </span><span style="color: #339933; font-size: small;">+</span><span style="font-size: small;"> width</span><span style="color: #339933; font-size: small;">/</span><span style="font-size: small;">8, y </span><span style="color: #339933; font-size: small;">+</span><span style="font-size: small;"> 7</span><span style="color: #339933; font-size: small;">*</span><span style="font-size: small;">height</span><span style="color: #339933; font-size: small;">/</span><span style="font-size: small;">8, 3</span><span style="color: #339933; font-size: small;">*</span><span style="font-size: small;">width</span><span style="color: #339933; font-size: small;">/</span><span style="font-size: small;">4, height</span><span style="color: #339933; font-size: small;">/</span><span style="font-size: small;">4, 0, 180</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> lines </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: #cc66cc; font-size: small;">16</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">double</span><span style="font-size: small;"> xi </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> x </span><span style="color: #339933; font-size: small;">+</span><span style="font-size: small;"> width</span><span style="color: #339933; font-size: small;">/</span><span style="color: #cc66cc; font-size: small;">8.0</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">double</span><span style="font-size: small;"> yi </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> y </span><span style="color: #339933; font-size: small;">+</span><span style="font-size: small;"> height</span><span style="color: #339933; font-size: small;">/</span><span style="color: #cc66cc; font-size: small;">2.0</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">double</span><span style="font-size: small;"> step_x </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> 3.0</span><span style="color: #339933; font-size: small;">*</span><span style="font-size: small;">width</span><span style="color: #339933; font-size: small;">/</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">4</span><span style="color: #339933; font-size: small;">*</span><span style="font-size: small;">lines</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">double</span><span style="font-size: small;"> step_y </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> height</span><span style="color: #339933; font-size: small;">/</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">2.0</span><span style="color: #339933; font-size: small;">*</span><span style="font-size: small;">lines</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">drawLine</span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">xi, </span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">yi, </span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="color: #009900; font-size: small;">)</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">xi</span><span style="color: #339933; font-size: small;">+</span><span style="font-size: small;">step_x</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">, </span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="color: #009900; font-size: small;">)</span><span style="color: #009900; font-size: small;">(</span> y<span style="color: #339933; font-size: small;">+</span><span style="font-size: small;">height</span><span style="color: #339933; font-size: small;">-</span><span style="font-size: small;">2</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">for</span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> i</span><span style="color: #339933; font-size: small;">=</span><span style="color: #cc66cc; font-size: small;">0</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> i </span><span style="color: #339933; font-size: small;"><</span><span style="font-size: small;"> lines</span><span style="color: #339933; font-size: small;">/</span><span style="color: #cc66cc; font-size: small;">2</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">++</span><span style="font-size: small;">i</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> xi </span><span style="color: #339933; font-size: small;">+=</span><span style="font-size: small;"> step_x</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> yi </span><span style="color: #339933; font-size: small;">-=</span><span style="font-size: small;"> step_y</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">drawLine</span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">xi, </span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">yi, </span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">xi, </span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="color: #009900; font-size: small;">)</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">y</span><span style="color: #339933; font-size: small;">+</span><span style="font-size: small;">height</span><span style="color: #339933; font-size: small;">-</span><span style="font-size: small;">2.0</span><span style="color: #009900; font-size: small;">)</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">for</span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> i</span><span style="color: #339933; font-size: small;">=</span><span style="color: #cc66cc; font-size: small;">1</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> i </span><span style="color: #339933; font-size: small;"><</span><span style="font-size: small;"> lines</span><span style="color: #339933; font-size: small;">/</span><span style="color: #cc66cc; font-size: small;">2</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">++</span><span style="font-size: small;">i</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> xi </span><span style="color: #339933; font-size: small;">+=</span><span style="font-size: small;"> step_x</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> yi </span><span style="color: #339933; font-size: small;">+=</span><span style="font-size: small;"> step_y</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">drawLine</span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">xi, </span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">yi, </span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">xi, </span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="color: #009900; font-size: small;">)</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">y</span><span style="color: #339933; font-size: small;">+</span><span style="font-size: small;">height</span><span style="color: #339933; font-size: small;">-</span><span style="font-size: small;">2.0</span><span style="color: #009900; font-size: small;">)</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> xi </span><span style="color: #339933; font-size: small;">+=</span><span style="font-size: small;"> step_x</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> yi </span><span style="color: #339933; font-size: small;">+=</span><span style="font-size: small;"> step_y</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">drawLine</span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">xi, </span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">yi, </span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="color: #009900; font-size: small;">)</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">xi</span><span style="color: #339933; font-size: small;">-</span><span style="font-size: small;">step_x</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">, </span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="color: #009900; font-size: small;">)</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">y</span><span style="color: #339933; font-size: small;">+</span><span style="font-size: small;">height</span><span style="color: #339933; font-size: small;">-</span><span style="font-size: small;">2.0</span><span style="color: #009900; font-size: small;">)</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> g.</span><span style="color: #006633; font-size: small;">setColor</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">oldPen</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: black; font-size: small; font-weight: bold;">public</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">class</span><span style="font-size: small;"> Main </span><span style="color: black; font-size: small; font-weight: bold;">extends</span><span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Ajframe+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">JFrame</span></a> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> Main</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> Locations Q </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> enableEvents</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Aawtevent+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">AWTEvent</span></a>.</span><span style="color: #006633; font-size: small;">WINDOW_EVENT_MASK</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> setLocation</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">100, 100</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> setSize</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">640, 480</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> setTitle</span><span style="color: #009900; font-size: small;">(</span><span style="color: blue; font-size: small;">"Eight Queens Problem (DFS using Backtracing)"</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> Board canvas </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">new</span><span style="font-size: small;"> Board </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> Q </span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> button </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">new</span><span style="font-size: small;"> MyButton</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> buttonclk </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">new</span><span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Aactionlistener+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">ActionListener</span></a></span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">public</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">void</span><span style="font-size: small;"> actionPerformed</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Aactionevent+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">ActionEvent</span></a> e</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> Main.</span><span style="color: #006633; font-size: small;">go</span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">true</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> Main.</span><span style="color: #006633; font-size: small;">window</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">repaint</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> button.</span><span style="color: #006633; font-size: small;">addActionListener</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">buttonclk</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> setLayout</span><span style="color: #009900; font-size: small;">(</span><span style="color: black; font-size: small; font-weight: bold;">new</span><span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Aborderlayout+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">BorderLayout</span></a></span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> add</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">canvas, <a href="http://www.google.com/search?hl=en&q=allinurl%3Aborderlayout+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">BorderLayout</span></a>.</span><span style="color: #006633; font-size: small;">CENTER</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> add</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">button, <a href="http://www.google.com/search?hl=en&q=allinurl%3Aborderlayout+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">BorderLayout</span></a>.</span><span style="color: #006633; font-size: small;">SOUTH</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> setVisible</span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">true</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> @Override</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">public</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">void</span><span style="font-size: small;"> processWindowEvent</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Awindowevent+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">WindowEvent</span></a> event </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">if</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> event.</span><span style="color: #006633; font-size: small;">getID</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">==</span><span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Awindowevent+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">WindowEvent</span></a>.</span><span style="color: #006633; font-size: small;">WINDOW_CLOSING</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Asystem+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">System</span></a>.</span><span style="color: #006633; font-size: small;">exit</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> 0 </span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: green; font-size: small; font-style: italic; font-weight: bold;">/**</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: green; font-size: small; font-style: italic; font-weight: bold;"> * @param args the command line arguments</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: green; font-size: small; font-style: italic; font-weight: bold;"> */</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">public</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">static</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">void</span><span style="font-size: small;"> main</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Astring+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">String</span></a></span><span style="color: #009900; font-size: small;">[</span><span style="color: #009900; font-size: small;">]</span><span style="font-size: small;"> args</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> size</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> Scanner in </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">new</span><span style="font-size: small;"> Scanner</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Asystem+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">System</span></a>.</span><span style="color: #006633; font-size: small;">in</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Asystem+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">System</span></a>.</span><span style="color: #006633; font-size: small;">out</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">println</span><span style="color: #009900; font-size: small;">(</span><span style="color: blue; font-size: small;">"Eight Queen Problem (DFS using Backtracing)"</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #666666; font-size: small; font-style: italic;">//System.out.print("N : ");</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #666666; font-size: small; font-style: italic;">//size = in.nextInt( );</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #666666; font-size: small; font-style: italic;">//System.out.println("Wait .... ");</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> size </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: #cc66cc; font-size: small;">8</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> Locations queens </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">new</span><span style="font-size: small;"> Locations</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">size</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> </span><span style="color: #666666; font-size: small; font-style: italic;">// stores row of queens</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> Main.</span><span style="color: #006633; font-size: small;">solution</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> queens</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Aeventqueue+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">EventQueue</span></a>.</span><span style="color: #006633; font-size: small;">invokeLater</span><span style="color: #009900; font-size: small;">(</span><span style="color: black; font-size: small; font-weight: bold;">new</span><span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Arunnable+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Runnable</span></a></span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">public</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">void</span><span style="font-size: small;"> run</span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> Main.</span><span style="color: #006633; font-size: small;">window</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">new</span><span style="font-size: small;"> Main</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">Main.</span><span style="color: #006633; font-size: small;">solution</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Arandom+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Random</span></a> dice </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">new</span><span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Arandom+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Random</span></a></span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Asystem+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">System</span></a>.</span><span style="color: #006633; font-size: small;">currentTimeMillis</span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">)</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">do</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> initial </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> dice.</span><span style="color: #006633; font-size: small;">nextInt</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">size</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">at</span><span style="color: #009900; font-size: small;">[</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">queens.</span><span style="color: #006633; font-size: small;">top</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">++</span><span style="color: #009900; font-size: small;">]</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> initial</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">while</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> solve </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">queens, window</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">==</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">false</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Aeventqueue+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">EventQueue</span></a>.</span><span style="color: #006633; font-size: small;">invokeLater</span><span style="color: #009900; font-size: small;">(</span><span style="color: black; font-size: small; font-weight: bold;">new</span><span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Arunnable+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Runnable</span></a></span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">public</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">void</span><span style="font-size: small;"> run</span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> Main.</span><span style="color: #006633; font-size: small;">button</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">setText</span><span style="color: #009900; font-size: small;">(</span><span style="color: blue; font-size: small;">"D O N E"</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> Main.</span><span style="color: #006633; font-size: small;">button</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">removeActionListener</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">buttonclk</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> buttonclk </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">new</span><span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Aactionlistener+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">ActionListener</span></a></span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">public</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">void</span><span style="font-size: small;"> actionPerformed</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Aactionevent+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">ActionEvent</span></a> e</span><span style="color: #009900; font-size: small;">)</span> <span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Ajoptionpane+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">JOptionPane</span></a>.</span><span style="color: #006633; font-size: small;">showMessageDialog</span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">null</span><span style="font-size: small;">, </span><span style="color: blue; font-size: small;">"THANK YOU. source code at http://rooparam.blogspot.com"</span><span style="font-size: small;">, </span><span style="color: blue; font-size: small;">"rooparam"</span><span style="font-size: small;">, <a href="http://www.google.com/search?hl=en&q=allinurl%3Ajoptionpane+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">JOptionPane</span></a>.</span><span style="color: #006633; font-size: small;">INFORMATION_MESSAGE</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> Main.</span><span style="color: #006633; font-size: small;">button</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">addActionListener</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">buttonclk</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Asystem+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">System</span></a>.</span><span style="color: #006633; font-size: small;">out</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">println</span><span style="color: #009900; font-size: small;">(</span><span style="color: blue; font-size: small;">"Positions of queens in Rows from left to right"</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">for</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> i</span><span style="color: #339933; font-size: small;">=</span><span style="color: #cc66cc; font-size: small;">0</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> i</span><span style="color: #339933; font-size: small;"><</span><span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">at</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">length</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">++</span><span style="font-size: small;">i </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Asystem+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">System</span></a>.</span><span style="color: #006633; font-size: small;">out</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">printf</span><span style="color: #009900; font-size: small;">(</span><span style="color: blue; font-size: small;">"%d "</span><span style="font-size: small;">, queens.</span><span style="color: #006633; font-size: small;">at</span><span style="color: #009900; font-size: small;">[</span><span style="font-size: small;">i</span><span style="color: #009900; font-size: small;">]</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Asystem+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">System</span></a>.</span><span style="color: #006633; font-size: small;">out</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">println</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">private</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">static</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">boolean</span><span style="font-size: small;"> solve</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">Locations queens, <a href="http://www.google.com/search?hl=en&q=allinurl%3Aframe+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Frame</span></a></span> window<span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">if</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">queens.</span><span style="color: #006633; font-size: small;">top</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">>=</span><span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">at</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">length</span><span style="color: #009900; font-size: small;">)</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">return</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">true</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> Main.</span><span style="color: #006633; font-size: small;">go</span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">false</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">while</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">(</span><span style="color: #339933; font-size: small;">!</span><span style="font-size: small;">proceed</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">try</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Athread+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Thread</span></a>.</span><span style="color: #006633; font-size: small;">sleep</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">100</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">catch</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Ainterruptedexception+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">InterruptedException</span></a> ex</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> Logger.</span><span style="color: #006633; font-size: small;">getLogger</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">Main.</span><span style="color: black; font-size: small; font-weight: bold;">class</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">getName</span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">)</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">log</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">Level.</span><span style="color: #006633; font-size: small;">SEVERE</span><span style="font-size: small;">, </span><span style="color: #000066; font-size: small; font-weight: bold;">null</span><span style="font-size: small;">, ex</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">try</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Aeventqueue+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">EventQueue</span></a>.</span><span style="color: #006633; font-size: small;">invokeAndWait</span><span style="color: #009900; font-size: small;">(</span><span style="color: black; font-size: small; font-weight: bold;">new</span><span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Arunnable+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Runnable</span></a></span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">public</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">void</span><span style="font-size: small;"> run</span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> Main.</span><span style="color: #006633; font-size: small;">window</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">repaint</span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">catch</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Ainterruptedexception+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">InterruptedException</span></a> ex</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> Logger.</span><span style="color: #006633; font-size: small;">getLogger</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">Main.</span><span style="color: black; font-size: small; font-weight: bold;">class</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">getName</span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">)</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">log</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">Level.</span><span style="color: #006633; font-size: small;">SEVERE</span><span style="font-size: small;">, </span><span style="color: #000066; font-size: small; font-weight: bold;">null</span><span style="font-size: small;">, ex</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">catch</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"><a href="http://www.google.com/search?hl=en&q=allinurl%3Ainvocationtargetexception+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">InvocationTargetException</span></a> ex</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> Logger.</span><span style="color: #006633; font-size: small;">getLogger</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">Main.</span><span style="color: black; font-size: small; font-weight: bold;">class</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">getName</span><span style="color: #009900; font-size: small;">(</span><span style="color: #009900; font-size: small;">)</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">log</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">Level.</span><span style="color: #006633; font-size: small;">SEVERE</span><span style="font-size: small;">, </span><span style="color: #000066; font-size: small; font-weight: bold;">null</span><span style="font-size: small;">, ex</span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">for</span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> i</span><span style="color: #339933; font-size: small;">=</span><span style="color: #cc66cc; font-size: small;">0</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> i </span><span style="color: #339933; font-size: small;"><</span><span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">at</span><span style="font-size: small;">.</span><span style="color: #006633; font-size: small;">length</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">++</span><span style="font-size: small;">i</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">if</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> isSafe </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> queens, i, queens.</span><span style="color: #006633; font-size: small;">top</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">at</span><span style="color: #009900; font-size: small;">[</span><span style="font-size: small;">queens.</span><span style="color: #006633; font-size: small;">top</span><span style="color: #339933; font-size: small;">++</span><span style="color: #009900; font-size: small;">]</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> i</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">if</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> solve </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> queens, window</span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">return</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">true</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">top</span><span style="color: #339933; font-size: small;">--;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">return</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">false</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">static</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">boolean</span><span style="font-size: small;"> isSafe</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;">Locations queens, </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> check, </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span> col<span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">for</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> i</span><span style="color: #339933; font-size: small;">=</span><span style="color: #cc66cc; font-size: small;">0</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> i </span><span style="color: #339933; font-size: small;"><</span><span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">top</span><span style="color: #339933; font-size: small;">;</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">++</span><span style="font-size: small;">i </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> col_i </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> i</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> row_i </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> queens.</span><span style="color: #006633; font-size: small;">at</span><span style="color: #009900; font-size: small;">[</span><span style="font-size: small;">i</span><span style="color: #009900; font-size: small;">]</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> col_test </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> col</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">int</span><span style="font-size: small;"> row_test </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> check</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #666666; font-size: small; font-style: italic;">// checking whether in same coloumn of in same row</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">if</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> col_i </span><span style="color: #339933; font-size: small;">==</span><span style="font-size: small;"> col_test </span><span style="color: #339933; font-size: small;">||</span><span style="font-size: small;"> row_i </span><span style="color: #339933; font-size: small;">==</span><span style="font-size: small;"> row_test </span><span style="color: #009900; font-size: small;">)</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">return</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">false</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #666666; font-size: small; font-style: italic;">// digonal check</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">if</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> col_i </span><span style="color: #339933; font-size: small;">+</span><span style="font-size: small;"> row_i </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">==</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> col_test </span><span style="color: #339933; font-size: small;">+</span><span style="font-size: small;"> row_test </span><span style="color: #009900; font-size: small;">)</span> <span style="color: #009900; font-size: small;">)</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">return</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">false</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">if</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> col_i </span><span style="color: #339933; font-size: small;">-</span><span style="font-size: small;"> row_i </span><span style="color: #009900; font-size: small;">)</span><span style="font-size: small;"> </span><span style="color: #339933; font-size: small;">==</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> col_test </span><span style="color: #339933; font-size: small;">-</span><span style="font-size: small;"> row_test </span><span style="color: #009900; font-size: small;">)</span> <span style="color: #009900; font-size: small;">)</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">return</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">false</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">return</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">true</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">static</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">boolean</span><span style="font-size: small;"> proceed </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">false</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">static</span><span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Aframe+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">Frame</span></a> window </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">null</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">static</span><span style="font-size: small;"> Locations solution </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">null</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">public</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">static</span><span style="font-size: small;"> </span><span style="color: #000066; font-size: small; font-weight: bold;">void</span><span style="font-size: small;"> go</span><span style="color: #009900; font-size: small;">(</span><span style="color: #000066; font-size: small; font-weight: bold;">boolean</span><span style="font-size: small;"> b</span><span style="color: #009900; font-size: small;">)</span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> myLock.</span><span style="color: #006633; font-size: small;">lock</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">try</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> proceed </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> b</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">finally</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">{</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> myLock.</span><span style="color: #006633; font-size: small;">unlock</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">public</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">static</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">final</span><span style="font-size: small;"> Lock myLock </span><span style="color: #339933; font-size: small;">=</span><span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">new</span><span style="font-size: small;"> ReentrantLock</span><span style="color: #009900; font-size: small;">(</span><span style="font-size: small;"> </span><span style="color: #009900; font-size: small;">)</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">static</span><span style="font-size: small;"> MyButton button</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="font-size: small;"> </span><span style="color: black; font-size: small; font-weight: bold;">static</span><span style="font-size: small;"> <a href="http://www.google.com/search?hl=en&q=allinurl%3Aactionlistener+java.sun.com&btnI=I%27m%20Feeling%20Lucky" style="color: #000060;"><span style="color: #003399;">ActionListener</span></a> buttonclk</span><span style="color: #339933; font-size: small;">;</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<span style="color: #009900; font-size: small;">}</span><br />
</div>
<br />
</li>
<li style="color: #003030; font-family: 'Courier New',Courier,monospace; font-size-adjust: none; font-size: 130%; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; vertical-align: top;"><div style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0pt; padding: 0pt; vertical-align: top;">
<br />
</div>
<br />
</li>
</ol>
</div>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com1tag:blogger.com,1999:blog-4276715425787171951.post-70296782604366480142009-11-09T10:19:00.001+05:302009-11-09T10:21:26.940+05:30Extendible Hashing Implementation<div class="cpp" style="font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"><ol><li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;">/*</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * ExtendedHashing.cpp</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * </span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * Copyright 2009 roKB <rooparambhakar@gmail.com></span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * </span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * This program is free software; you can redistribute it and/or modify</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * it under the terms of the GNU General Public License as published by</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * the Free Software Foundation; either version 2 of the License, or</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * (at your option) any later version.</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * </span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * This program is distributed in the hope that it will be useful,</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * GNU General Public License for more details.</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * </span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * You should have received a copy of the GNU General Public License</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * along with this program; if not, write to the Free Software</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * MA 02110-1301, USA.</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> */</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #339900;">#include <string></span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #339900;">#include <cassert></span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #339900;">#include <iostream></span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #339900;">#include <cstdio></span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #339900;">#include <cstdlib></span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">int</span> hashCode<span style="color: #008000;">(</span>std<span style="color: #008080;">::</span><span style="color: #007788;">string</span> <span style="color: #0000ff;">const</span> <span style="color: #000040;">&</span> key<span style="color: #008000;">)</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;">/*</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * calculates the hash of key using polynomial expansion,</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * with x = 37</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> */</span> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">long</span> x <span style="color: #000080;">=</span> <span style="color: #0000dd;">41L</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> n <span style="color: #000080;">=</span> key.<span style="color: #007788;">length</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">long</span> value <span style="color: #000080;">=</span> <span style="color: #0000dd;">0L</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">while</span><span style="color: #008000;">(</span> n<span style="color: #000040;">--</span> <span style="color: #000080;">></span> 0 <span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> value <span style="color: #000040;">*</span><span style="color: #000080;">=</span> x<span style="color: #008080;">;</span> value <span style="color: #000040;">+</span><span style="color: #000080;">=</span> key<span style="color: #008000;">[</span>n<span style="color: #008000;">]</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">static_cast</span><span style="color: #000080;"><</span><span style="color: #0000ff;">int</span><span style="color: #000080;">></span><span style="color: #008000;">(</span>value<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #666666;">// ------------------------------------------------------------------------</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #666666;">// ------------------------------------------------------------------------</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">struct</span> Student</div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #007788;">string</span> entryNo<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #007788;">string</span> name<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">}</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;">std<span style="color: #008080;">::</span><span style="color: #007788;">ostream</span><span style="color: #000040;">&</span> operator <span style="color: #000080;"><<</span> <span style="color: #008000;">(</span>std<span style="color: #008080;">::</span><span style="color: #007788;">ostream</span><span style="color: #000040;">&</span> out, Student<span style="color: #000040;">&</span> s<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> out <span style="color: #000080;"><<</span> s.<span style="color: #007788;">entryNo</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">" : "</span> <span style="color: #000080;"><<</span> s.<span style="color: #007788;">name</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> out<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #666666;">// ------------------------------------------------------------------------</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #666666;">// ------------------------------------------------------------------------</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">struct</span> Node </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;">/* sentinal nodes of linked list */</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Node <span style="color: #000040;">*</span>next<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">}</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">struct</span> Pair <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> first<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Student <span style="color: #000040;">*</span>second<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> ~Pair<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span>second <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000dd;">delete</span> second<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">}</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">struct</span> InternalNode <span style="color: #008080;">:</span> <span style="color: #0000ff;">public</span> Node</div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;">/* internal nodes of linked list */</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Pair <span style="color: #000040;">*</span>element<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> ~InternalNode<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000dd;">delete</span> element<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">}</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">class</span> LinkedList </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;">/*</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * buckets in hash table</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> */</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">public</span><span style="color: #008080;">:</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> LinkedList<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> head <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> Node<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> head<span style="color: #000040;">-</span><span style="color: #000080;">></span>next <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> ~LinkedList<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> del<span style="color: #008000;">(</span>head<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">void</span> insert<span style="color: #008000;">(</span>Student <span style="color: #000040;">&</span> elem, <span style="color: #0000ff;">int</span> hashkey<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #666666;">// create hash, data pair</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Pair <span style="color: #000040;">*</span>data <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> Pair<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> data<span style="color: #000040;">-</span><span style="color: #000080;">></span>first <span style="color: #000080;">=</span> hashkey<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> data<span style="color: #000040;">-</span><span style="color: #000080;">></span>second <span style="color: #000080;">=</span> <span style="color: #000040;">&</span>elem<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #666666;">// create node in list</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> InternalNode <span style="color: #000040;">*</span>temp <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> InternalNode<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> temp<span style="color: #000040;">-</span><span style="color: #000080;">></span>next <span style="color: #000080;">=</span> head<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> temp<span style="color: #000040;">-</span><span style="color: #000080;">></span>element <span style="color: #000080;">=</span> data<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> head<span style="color: #000040;">-</span><span style="color: #000080;">></span>next <span style="color: #000080;">=</span> temp<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Student<span style="color: #000040;">*</span> search<span style="color: #008000;">(</span><span style="color: #0000ff;">int</span> hashkey<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Node <span style="color: #000040;">*</span>current <span style="color: #000080;">=</span> head<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>current <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span><span style="color: #0000ff;">static_cast</span><span style="color: #000080;"><</span>InternalNode<span style="color: #000040;">*</span><span style="color: #000080;">></span><span style="color: #008000;">(</span>current<span style="color: #008000;">)</span><span style="color: #000040;">-</span><span style="color: #000080;">></span>element<span style="color: #000040;">-</span><span style="color: #000080;">></span>first <span style="color: #000080;">==</span> hashkey<span style="color: #008000;">)</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">static_cast</span><span style="color: #000080;"><</span>InternalNode<span style="color: #000040;">*</span><span style="color: #000080;">></span><span style="color: #008000;">(</span>current<span style="color: #008000;">)</span><span style="color: #000040;">-</span><span style="color: #000080;">></span>element<span style="color: #000040;">-</span><span style="color: #000080;">></span>second<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> current <span style="color: #000080;">=</span> current<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">void</span> <span style="color: #0000dd;">remove</span><span style="color: #008000;">(</span><span style="color: #0000ff;">int</span> hashkey<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Node <span style="color: #000040;">*</span>current <span style="color: #000080;">=</span> head<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Node <span style="color: #000040;">*</span>parent <span style="color: #000080;">=</span> head<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>current <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span><span style="color: #0000ff;">static_cast</span><span style="color: #000080;"><</span>InternalNode<span style="color: #000040;">*</span><span style="color: #000080;">></span><span style="color: #008000;">(</span>current<span style="color: #008000;">)</span><span style="color: #000040;">-</span><span style="color: #000080;">></span>element<span style="color: #000040;">-</span><span style="color: #000080;">></span>first <span style="color: #000080;">==</span> hashkey<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #666666;">// fix links in list then remove and return</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> parent<span style="color: #000040;">-</span><span style="color: #000080;">></span>next <span style="color: #000080;">=</span> current<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> current<span style="color: #000040;">-</span><span style="color: #000080;">></span>next <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> del<span style="color: #008000;">(</span>current<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> parent <span style="color: #000080;">=</span> current<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> current <span style="color: #000080;">=</span> current<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">void</span> removeAll<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> del<span style="color: #008000;">(</span>head<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> head<span style="color: #000040;">-</span><span style="color: #000080;">></span>next <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">void</span> print<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> InternalNode <span style="color: #000040;">*</span>current <span style="color: #000080;">=</span> <span style="color: #0000ff;">static_cast</span><span style="color: #000080;"><</span>InternalNode<span style="color: #000040;">*</span><span style="color: #000080;">></span><span style="color: #008000;">(</span>head<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>current <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> i <span style="color: #000080;"><<</span> <span style="color: #FF0000;">" : hashkey(0x"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">hex</span> <span style="color: #000080;"><<</span> <span style="color: #0000ff;">static_cast</span><span style="color: #000080;"><</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">int</span><span style="color: #000080;">></span><span style="color: #008000;">(</span> current<span style="color: #000040;">-</span><span style="color: #000080;">></span>element<span style="color: #000040;">-</span><span style="color: #000080;">></span>first <span style="color: #008000;">)</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">") <"</span> <span style="color: #000080;"><<</span> <span style="color: #000040;">*</span><span style="color: #008000;">(</span>current<span style="color: #000040;">-</span><span style="color: #000080;">></span>element<span style="color: #000040;">-</span><span style="color: #000080;">></span>second<span style="color: #008000;">)</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">">"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> current <span style="color: #000080;">=</span> <span style="color: #0000ff;">static_cast</span><span style="color: #000080;"><</span>InternalNode<span style="color: #000040;">*</span><span style="color: #000080;">></span><span style="color: #008000;">(</span>current<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #000040;">++</span>i<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Node <span style="color: #000040;">*</span>getList<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> head<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">private</span><span style="color: #008080;">:</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">void</span> del<span style="color: #008000;">(</span>Node <span style="color: #000040;">*</span>node<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span>node <span style="color: #000080;">==</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> del<span style="color: #008000;">(</span>node<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000dd;">delete</span> node<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Node <span style="color: #000040;">*</span>head<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">}</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">class</span> Bucket </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;">/*</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * uses LinkedList for storage</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * bucket overflow and underflow is left for xtendedHashing functions</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * they should check for underflow and overflow in bucket, otherwise</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * program will terminate</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> */</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">public</span><span style="color: #008080;">:</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Bucket<span style="color: #008000;">(</span><span style="color: #0000ff;">int</span> c, <span style="color: #0000ff;">int</span> s <span style="color: #000080;">=</span> 0<span style="color: #008000;">)</span> <span style="color: #008080;">:</span> sig_bits<span style="color: #008000;">(</span>s<span style="color: #008000;">)</span>, cap<span style="color: #008000;">(</span>c<span style="color: #008000;">)</span>, sz<span style="color: #008000;">(</span>0<span style="color: #008000;">)</span>, code<span style="color: #008000;">(</span>0<span style="color: #008000;">)</span>, root<span style="color: #008000;">(</span><span style="color: #0000ff;">false</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> data <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> LinkedList<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> ~Bucket<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000dd;">delete</span> data<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> capacity<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> cap<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> size<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> sz<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">void</span> insert<span style="color: #008000;">(</span>Student<span style="color: #000040;">&</span> elem, <span style="color: #0000ff;">int</span> hashkey<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> data<span style="color: #000040;">-</span><span style="color: #000080;">></span>insert<span style="color: #008000;">(</span>elem, hashkey<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #000040;">++</span>sz<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span>root<span style="color: #008000;">)</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000dd;">assert</span><span style="color: #008000;">(</span> <span style="color: #008000;">(</span> size<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #000080;"><=</span> capacity<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">)</span> <span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Student<span style="color: #000040;">*</span> search<span style="color: #008000;">(</span><span style="color: #0000ff;">int</span> hashkey<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> data<span style="color: #000040;">-</span><span style="color: #000080;">></span>search<span style="color: #008000;">(</span>hashkey<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">void</span> <span style="color: #0000dd;">remove</span><span style="color: #008000;">(</span><span style="color: #0000ff;">int</span> hashkey<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span>search<span style="color: #008000;">(</span>hashkey<span style="color: #008000;">)</span> <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #000040;">--</span>sz<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> data<span style="color: #000040;">-</span><span style="color: #000080;">></span><span style="color: #0000dd;">remove</span><span style="color: #008000;">(</span>hashkey<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000dd;">assert</span><span style="color: #008000;">(</span> <span style="color: #008000;">(</span>size<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #000080;">>=</span> 0<span style="color: #008000;">)</span> <span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">void</span> emptyBucket<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> data<span style="color: #000040;">-</span><span style="color: #000080;">></span>removeAll<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> sig_bits <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> sz <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">bool</span> isEmpty<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> size<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #000080;">==</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">void</span> print<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"----- <BUCKET ("</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> printcode<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">") > -----"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"SIG_BITS : "</span> <span style="color: #000080;"><<</span> sig_bits <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> data<span style="color: #000040;">-</span><span style="color: #000080;">></span>print<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Node<span style="color: #000040;">*</span> getList<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> data<span style="color: #000040;">-</span><span style="color: #000080;">></span>getList<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> getSIG_BITS<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> sig_bits<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">void</span> setSIG_BITS<span style="color: #008000;">(</span><span style="color: #0000ff;">int</span> s<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> sig_bits <span style="color: #000080;">=</span> s<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000dd;">assert</span><span style="color: #008000;">(</span> <span style="color: #008000;">(</span>sig_bits <span style="color: #000080;">>=</span> 0<span style="color: #008000;">)</span> <span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">void</span> setCODE<span style="color: #008000;">(</span><span style="color: #0000ff;">int</span> c<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> code <span style="color: #000080;">=</span> c<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">void</span> setROOT<span style="color: #008000;">(</span><span style="color: #0000ff;">bool</span> state<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> root <span style="color: #000080;">=</span> state<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">private</span><span style="color: #008080;">:</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">void</span> printcode<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> length <span style="color: #000080;">=</span> sig_bits<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> temp <span style="color: #000080;">=</span> code<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>length<span style="color: #000040;">--</span> <span style="color: #000080;">></span> 0<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> temp<span style="color: #000040;">%</span><span style="color:#800080;">2</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> temp <span style="color: #000080;">>>=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> LinkedList <span style="color: #000040;">*</span>data<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> sig_bits<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> cap<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> sz<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> code<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">bool</span> root<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">}</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">struct</span> TrieNode</div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Bucket <span style="color: #000040;">*</span>page<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> TrieNode <span style="color: #000040;">*</span>next<span style="color: #008000;">[</span>2<span style="color: #008000;">]</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> TrieNode <span style="color: #000040;">*</span>parent<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> ~TrieNode<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span>page <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000dd;">delete</span> page<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">}</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">class</span> HashTable</div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;">/*</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * at last we are at the implementation of Extendible-hashTable ^v^</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * uses tries index for bucket lookup</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> * "now is the time to show your coding skills rrc"</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #ff0000; font-style: italic;"> */</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">public</span><span style="color: #008080;">:</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> HashTable<span style="color: #008000;">(</span><span style="color: #0000ff;">int</span> buk <span style="color: #000080;">=</span> DFL_BUCKET_SIZE<span style="color: #008000;">)</span> <span style="color: #008080;">:</span> bucket_size<span style="color: #008000;">(</span>buk<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> sig_bits <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #666666;">//root = false;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> index <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> TrieNode<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> index<span style="color: #000040;">-</span><span style="color: #000080;">></span>page <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> Bucket<span style="color: #008000;">(</span>bucket_size, sig_bits<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> index<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>0<span style="color: #008000;">]</span> <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> index<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>1<span style="color: #008000;">]</span> <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> index<span style="color: #000040;">-</span><span style="color: #000080;">></span>parent <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> no_of_buckets <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> ~HashTable<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> del<span style="color: #008000;">(</span>index<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Student<span style="color: #000040;">*</span> search<span style="color: #008000;">(</span>std<span style="color: #008080;">::</span><span style="color: #007788;">string</span> number<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> code<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> hashkey <span style="color: #000080;">=</span> hashCode<span style="color: #008000;">(</span>number<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> TrieNode <span style="color: #000040;">*</span>node <span style="color: #000080;">=</span> findNode<span style="color: #008000;">(</span>hashkey, <span style="color: #000040;">&</span>code<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> node<span style="color: #000040;">-</span><span style="color: #000080;">></span>page<span style="color: #000040;">-</span><span style="color: #000080;">></span>search<span style="color: #008000;">(</span>hashkey<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">void</span> insert<span style="color: #008000;">(</span>Student stu<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Student <span style="color: #000040;">&</span> st <span style="color: #000080;">=</span> <span style="color: #000040;">*</span><span style="color: #0000dd;">new</span> Student<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> st.<span style="color: #007788;">name</span> <span style="color: #000080;">=</span> stu.<span style="color: #007788;">name</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> st.<span style="color: #007788;">entryNo</span> <span style="color: #000080;">=</span> stu.<span style="color: #007788;">entryNo</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> hashkey <span style="color: #000080;">=</span> hashCode<span style="color: #008000;">(</span>st.<span style="color: #007788;">entryNo</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> code<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> TrieNode <span style="color: #000040;">*</span>node <span style="color: #000080;">=</span> findNode<span style="color: #008000;">(</span>hashkey, <span style="color: #000040;">&</span>code<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Bucket <span style="color: #000040;">*</span>page <span style="color: #000080;">=</span> node<span style="color: #000040;">-</span><span style="color: #000080;">></span>page<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #666666;">//if(root || page->size()+1 <= page->capacity())</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span>page<span style="color: #000040;">-</span><span style="color: #000080;">></span>size<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #000040;">+</span><span style="color: #0000dd;">1</span> <span style="color: #000080;"><=</span> page<span style="color: #000040;">-</span><span style="color: #000080;">></span>capacity<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #666666;">// insert in bucket</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #666666;">// page->setROOT(root);</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> page<span style="color: #000040;">-</span><span style="color: #000080;">></span>insert<span style="color: #008000;">(</span>st, hashkey<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #666666;">// page->setROOT(false);</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">{</span> <span style="color: #666666;">// bucket is full, make a new bucket</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #666666;">// step 7</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Bucket <span style="color: #000040;">*</span>newPage <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> Bucket<span style="color: #008000;">(</span>bucket_size<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> no_of_buckets<span style="color: #000040;">++</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #666666;">// step 8</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> LinkedList <span style="color: #000040;">*</span>Q <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> LinkedList<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> InternalNode <span style="color: #000040;">*</span>current <span style="color: #000080;">=</span> <span style="color: #0000ff;">static_cast</span><span style="color: #000080;"><</span>InternalNode<span style="color: #000040;">*</span><span style="color: #000080;">></span><span style="color: #008000;">(</span> page<span style="color: #000040;">-</span><span style="color: #000080;">></span>getList<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>current <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Q<span style="color: #000040;">-</span><span style="color: #000080;">></span>insert<span style="color: #008000;">(</span><span style="color: #000040;">*</span><span style="color: #008000;">(</span>current<span style="color: #000040;">-</span><span style="color: #000080;">></span>element<span style="color: #000040;">-</span><span style="color: #000080;">></span>second<span style="color: #008000;">)</span>, current<span style="color: #000040;">-</span><span style="color: #000080;">></span>element<span style="color: #000040;">-</span><span style="color: #000080;">></span>first<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> current <span style="color: #000080;">=</span> <span style="color: #0000ff;">static_cast</span><span style="color: #000080;"><</span>InternalNode<span style="color: #000040;">*</span><span style="color: #000080;">></span><span style="color: #008000;">(</span>current<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Q<span style="color: #000040;">-</span><span style="color: #000080;">></span>insert<span style="color: #008000;">(</span>st, hashkey<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #666666;">// step 9</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> oldD <span style="color: #000080;">=</span> page<span style="color: #000040;">-</span><span style="color: #000080;">></span>getSIG_BITS<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> MASK <span style="color: #000080;">=</span> 1 <span style="color: #000080;"><<</span> oldD<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> newPage<span style="color: #000040;">-</span><span style="color: #000080;">></span>setSIG_BITS<span style="color: #008000;">(</span>oldD <span style="color: #000040;">+</span> 1<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #666666;">// step 10</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> page<span style="color: #000040;">-</span><span style="color: #000080;">></span>emptyBucket<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> page<span style="color: #000040;">-</span><span style="color: #000080;">></span>setSIG_BITS<span style="color: #008000;">(</span>oldD <span style="color: #000040;">+</span> 1<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span>oldD<span style="color: #000040;">+</span>1 <span style="color: #000080;">></span> sig_bits<span style="color: #008000;">)</span><span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #000040;">++</span>sig_bits<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> node<span style="color: #000040;">-</span><span style="color: #000080;">></span>page <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> TrieNode <span style="color: #000040;">*</span>left <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> TrieNode<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> TrieNode <span style="color: #000040;">*</span>right <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> TrieNode<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> node<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>0<span style="color: #008000;">]</span> <span style="color: #000080;">=</span> left<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> node<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>1<span style="color: #008000;">]</span> <span style="color: #000080;">=</span> right<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> left<span style="color: #000040;">-</span><span style="color: #000080;">></span>page <span style="color: #000080;">=</span> page<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> right<span style="color: #000040;">-</span><span style="color: #000080;">></span>page <span style="color: #000080;">=</span> newPage<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> left<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>0<span style="color: #008000;">]</span> <span style="color: #000080;">=</span> left<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>1<span style="color: #008000;">]</span> <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span> left<span style="color: #000040;">-</span><span style="color: #000080;">></span>parent <span style="color: #000080;">=</span> node<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> right<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>0<span style="color: #008000;">]</span> <span style="color: #000080;">=</span> right<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>1<span style="color: #008000;">]</span> <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span> right<span style="color: #000040;">-</span><span style="color: #000080;">></span>parent <span style="color: #000080;">=</span> node<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> left<span style="color: #000040;">-</span><span style="color: #000080;">></span>page<span style="color: #000040;">-</span><span style="color: #000080;">></span>setCODE<span style="color: #008000;">(</span>code<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> right<span style="color: #000040;">-</span><span style="color: #000080;">></span>page<span style="color: #000040;">-</span><span style="color: #000080;">></span>setCODE<span style="color: #008000;">(</span>code <span style="color: #000040;">|</span> MASK<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> current <span style="color: #000080;">=</span> <span style="color: #0000ff;">static_cast</span><span style="color: #000080;"><</span>InternalNode<span style="color: #000040;">*</span><span style="color: #000080;">></span><span style="color: #008000;">(</span> Q<span style="color: #000040;">-</span><span style="color: #000080;">></span>getList<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #666666;">// root = true;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>current <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> insert<span style="color: #008000;">(</span> <span style="color: #000040;">*</span><span style="color: #008000;">(</span>current<span style="color: #000040;">-</span><span style="color: #000080;">></span>element<span style="color: #000040;">-</span><span style="color: #000080;">></span>second<span style="color: #008000;">)</span> <span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> current <span style="color: #000080;">=</span> <span style="color: #0000ff;">static_cast</span><span style="color: #000080;"><</span>InternalNode<span style="color: #000040;">*</span><span style="color: #000080;">></span><span style="color: #008000;">(</span> current<span style="color: #000040;">-</span><span style="color: #000080;">></span>next <span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #666666;">// root = false;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">void</span> <span style="color: #0000dd;">remove</span><span style="color: #008000;">(</span>std<span style="color: #008080;">::</span><span style="color: #007788;">string</span> number<span style="color: #008000;">)</span><span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> hashkey <span style="color: #000080;">=</span> hashCode<span style="color: #008000;">(</span>number<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> code<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> TrieNode <span style="color: #000040;">*</span>node <span style="color: #000080;">=</span> findNode<span style="color: #008000;">(</span>hashkey, <span style="color: #000040;">&</span>code<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Bucket <span style="color: #000040;">*</span>page <span style="color: #000080;">=</span> node<span style="color: #000040;">-</span><span style="color: #000080;">></span>page<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span>page<span style="color: #000040;">-</span><span style="color: #000080;">></span>search<span style="color: #008000;">(</span>hashkey<span style="color: #008000;">)</span> <span style="color: #000080;">==</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> page<span style="color: #000040;">-</span><span style="color: #000080;">></span><span style="color: #0000dd;">remove</span><span style="color: #008000;">(</span>hashkey<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span>page<span style="color: #000040;">-</span><span style="color: #000080;">></span>size<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #000080;">==</span> 0 <span style="color: #000040;">&&</span> node<span style="color: #000040;">-</span><span style="color: #000080;">></span>parent <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> TrieNode <span style="color: #000040;">*</span>parent <span style="color: #000080;">=</span> node<span style="color: #000040;">-</span><span style="color: #000080;">></span>parent<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> TrieNode <span style="color: #000040;">*</span>sibling <span style="color: #000080;">=</span> <span style="color: #008000;">(</span>parent<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>0<span style="color: #008000;">]</span> <span style="color: #000080;">==</span> node<span style="color: #008000;">)</span><span style="color: #008080;">?</span> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">(</span>parent<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>1<span style="color: #008000;">]</span><span style="color: #008000;">)</span> <span style="color: #008080;">:</span> <span style="color: #008000;">(</span>parent<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>0<span style="color: #008000;">]</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span>sibling<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>0<span style="color: #008000;">]</span> <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span> <span style="color: #000040;">||</span> sibling<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>1<span style="color: #008000;">]</span> <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> no_of_buckets<span style="color: #000040;">--</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> parent<span style="color: #000040;">-</span><span style="color: #000080;">></span>page <span style="color: #000080;">=</span> sibling<span style="color: #000040;">-</span><span style="color: #000080;">></span>page<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> sibling<span style="color: #000040;">-</span><span style="color: #000080;">></span>page <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> parent<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>0<span style="color: #008000;">]</span> <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> parent<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>1<span style="color: #008000;">]</span> <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> del<span style="color: #008000;">(</span>node<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> del<span style="color: #008000;">(</span>sibling<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> parent<span style="color: #000040;">-</span><span style="color: #000080;">></span>page<span style="color: #000040;">-</span><span style="color: #000080;">></span>setSIG_BITS<span style="color: #008000;">(</span>parent<span style="color: #000040;">-</span><span style="color: #000080;">></span>page<span style="color: #000040;">-</span><span style="color: #000080;">></span>getSIG_BITS<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #000040;">-</span> 1<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> MASK <span style="color: #000080;">=</span> 1 <span style="color: #000080;"><<</span> parent<span style="color: #000040;">-</span><span style="color: #000080;">></span>page<span style="color: #000040;">-</span><span style="color: #000080;">></span>getSIG_BITS<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> MASK <span style="color: #000040;">-</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> code <span style="color: #000040;">&</span><span style="color: #000080;">=</span> MASK<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> parent<span style="color: #000040;">-</span><span style="color: #000080;">></span>page<span style="color: #000040;">-</span><span style="color: #000080;">></span>setCODE<span style="color: #008000;">(</span>code<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> sig_bits <span style="color: #000080;">=</span> max_bits<span style="color: #008000;">(</span>index<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">void</span> print<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"-----------------------------------------"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"bucket.capacity : "</span> <span style="color: #000080;"><<</span> bucket_size <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\t</span>|||<span style="color: #000099; font-weight: bold;">\t</span>"</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"number ( buckets ) : "</span> <span style="color: #000080;"><<</span> no_of_buckets <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\t</span>|||<span style="color: #000099; font-weight: bold;">\t</span>"</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"max sig_bits : "</span> <span style="color: #000080;"><<</span> sig_bits <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> total <span style="color: #000080;">=</span> printNode<span style="color: #008000;">(</span>index<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"-----------------------------------------"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"elements in hashtable : "</span> <span style="color: #000080;"><<</span> total <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"-----------------------------------------"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">private</span><span style="color: #008080;">:</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> TrieNode<span style="color: #000040;">*</span> findNode<span style="color: #008000;">(</span><span style="color: #0000ff;">int</span> hashkey, <span style="color: #0000ff;">int</span> <span style="color: #000040;">*</span><span style="color: #0000ff;">const</span> code<span style="color: #008000;">)</span> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #666666;">// using lower sig_bits of hashCode to calculate key</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> d <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span> <span style="color: #666666;">// mask for calculating key from k</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> d <span style="color: #000080;"><<=</span> sig_bits<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> d <span style="color: #000040;">-</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span> <span style="color: #666666;">// all ones</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> key <span style="color: #000080;">=</span> hashkey <span style="color: #000040;">&</span> d<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #000040;">*</span>code <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> length <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> TrieNode <span style="color: #000040;">*</span>current <span style="color: #000080;">=</span> index<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>current <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span>current<span style="color: #000040;">-</span><span style="color: #000080;">></span>page <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> current<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span>current<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>key <span style="color: #000040;">&</span> 1<span style="color: #008000;">]</span> <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span><span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> current <span style="color: #000080;">=</span> current<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>key <span style="color: #000040;">&</span> 1<span style="color: #008000;">]</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> MASK <span style="color: #000080;">=</span> key<span style="color: #000040;">&</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span> <span style="color: #666666;">// current decision</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span>length <span style="color: #000040;">!</span><span style="color: #000080;">=</span> 0<span style="color: #008000;">)</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> MASK <span style="color: #000080;"><<=</span> length<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #000040;">*</span>code <span style="color: #000040;">|</span><span style="color: #000080;">=</span> MASK<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> key <span style="color: #000080;">>>=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #000040;">++</span>length<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000dd;">assert</span><span style="color: #008000;">(</span> 0 <span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #666666;">// should not come here.</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">void</span> del<span style="color: #008000;">(</span>TrieNode <span style="color: #000040;">*</span>node<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span>node <span style="color: #000080;">==</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> TrieNode <span style="color: #000040;">*</span>left, <span style="color: #000040;">*</span>right<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> left <span style="color: #000080;">=</span> node<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>0<span style="color: #008000;">]</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> right <span style="color: #000080;">=</span> node<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>1<span style="color: #008000;">]</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> del<span style="color: #008000;">(</span>left<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> del<span style="color: #008000;">(</span>right<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000dd;">delete</span> node<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> printNode<span style="color: #008000;">(</span>TrieNode <span style="color: #000040;">*</span>current<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span>current <span style="color: #000080;">==</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span>current<span style="color: #000040;">-</span><span style="color: #000080;">></span>page <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> current<span style="color: #000040;">-</span><span style="color: #000080;">></span>page<span style="color: #000040;">-</span><span style="color: #000080;">></span>print<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> current<span style="color: #000040;">-</span><span style="color: #000080;">></span>page<span style="color: #000040;">-</span><span style="color: #000080;">></span>size<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> number <span style="color: #000080;">=</span> printNode<span style="color: #008000;">(</span>current<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>0<span style="color: #008000;">]</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> number <span style="color: #000040;">+</span><span style="color: #000080;">=</span> printNode<span style="color: #008000;">(</span>current<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>1<span style="color: #008000;">]</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> number<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> max_bits<span style="color: #008000;">(</span>TrieNode <span style="color: #000040;">*</span>node<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">if</span><span style="color: #008000;">(</span>node<span style="color: #000040;">-</span><span style="color: #000080;">></span>page <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> node<span style="color: #000040;">-</span><span style="color: #000080;">></span>page<span style="color: #000040;">-</span><span style="color: #000080;">></span>getSIG_BITS<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> left <span style="color: #000080;">=</span> max_bits<span style="color: #008000;">(</span>node<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>0<span style="color: #008000;">]</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> right <span style="color: #000080;">=</span> max_bits<span style="color: #008000;">(</span>node<span style="color: #000040;">-</span><span style="color: #000080;">></span>next<span style="color: #008000;">[</span>1<span style="color: #008000;">]</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> max <span style="color: #000080;">=</span> <span style="color: #008000;">(</span>left <span style="color: #000080;">></span> right<span style="color: #008000;">)</span> <span style="color: #008080;">?</span> left <span style="color: #008080;">:</span> right<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> max<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">int</span> DFL_BUCKET_SIZE <span style="color: #000080;">=</span> <span style="color: #0000dd;">4</span><span style="color: #008080;">;</span> <span style="color: #666666;">// default bucket size</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> TrieNode <span style="color: #000040;">*</span>index<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> sig_bits<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> bucket_size<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> no_of_buckets<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #666666;">//bool root;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">}</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">int</span> printMenu<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">system</span><span style="color: #008000;">(</span><span style="color: #FF0000;">"clear"</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"-----------------------------------------"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Extendible Hashing Implementation."</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"-----------------------------------------"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span> 1. Insert a Record"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span> 2. Search a Record"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span> 3. Delete a Record"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span> 4. Show All Records"</span><span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span> 5. Delete All Records"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span> 6. Exit"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> choice<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\n</span>Choice : "</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cin</span> <span style="color: #000080;">>></span> choice<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span>.<span style="color: #007788;">flush</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> choice<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">void</span> credits<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">system</span><span style="color: #008000;">(</span><span style="color: #FF0000;">"clear"</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span> ----------------------------------------------"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span> /<span style="color: #000099; font-weight: bold;">\\</span>--------------------------------------------/<span style="color: #000099; font-weight: bold;">\\</span>"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>|| Thanks for evaluating our Extendible Hashing ||"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>|| <span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>Implementation.<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>||"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span> <span style="color: #000099; font-weight: bold;">\\</span>/--------------------------------------------<span style="color: #000099; font-weight: bold;">\\</span>/"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span> ----------------------------------------------"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>Implementors:-<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>2006ECS20<span style="color: #000099; font-weight: bold;">\t</span>Rooparam Choudhary<span style="color: #000099; font-weight: bold;">\t</span>(Main Coder)"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>2006ECS57<span style="color: #000099; font-weight: bold;">\t</span>Kumar Ranjeet<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>(Creative Head)"</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>enter to quit..."</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">getchar</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">int</span> main<span style="color: #008000;">(</span><span style="color: #008000;">)</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Enter bucket-size : "</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> n<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">char</span> ch<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cin</span> <span style="color: #000080;">>></span> n<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> HashTable <span style="color: #000040;">*</span>table <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> HashTable<span style="color: #008000;">(</span>n<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">while</span><span style="color: #008000;">(</span><span style="color: #0000ff;">true</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">int</span> choice <span style="color: #000080;">=</span> printMenu<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> ch <span style="color: #000080;">=</span> std<span style="color: #008080;">::</span><span style="color: #0000dd;">getchar</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #666666;">// eat newline</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">switch</span><span style="color: #008000;">(</span>choice<span style="color: #008000;">)</span> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">:</span> <span style="color: #666666;">// Insert a record</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Student st<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\n</span>Enter Student Name : "</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #007788;">getline</span><span style="color: #008000;">(</span>std<span style="color: #008080;">::</span><span style="color: #0000dd;">cin</span>, st.<span style="color: #007788;">name</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Enter Entry Number : "</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #007788;">getline</span><span style="color: #008000;">(</span>std<span style="color: #008080;">::</span><span style="color: #0000dd;">cin</span>, st.<span style="color: #007788;">entryNo</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> table<span style="color: #000040;">-</span><span style="color: #000080;">></span>insert<span style="color: #008000;">(</span>st<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">2</span><span style="color: #008080;">:</span> <span style="color: #666666;">// search a Record</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #007788;">string</span> entNum<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\n</span>Enter Entry Number: "</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #007788;">getline</span><span style="color: #008000;">(</span>std<span style="color: #008080;">::</span><span style="color: #0000dd;">cin</span>, entNum<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> Student <span style="color: #000040;">*</span>st <span style="color: #000080;">=</span> table<span style="color: #000040;">-</span><span style="color: #000080;">></span>search<span style="color: #008000;">(</span>entNum<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #000040;">*</span>st<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"enter to continue ..."</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> ch <span style="color: #000080;">=</span> std<span style="color: #008080;">::</span><span style="color: #0000dd;">getchar</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">3</span><span style="color: #008080;">:</span> <span style="color: #666666;">// delete a Record</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">{</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #007788;">string</span> entNum<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"<span style="color: #000099; font-weight: bold;">\n</span>Enter Entry Number: "</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #007788;">getline</span><span style="color: #008000;">(</span>std<span style="color: #008080;">::</span><span style="color: #0000dd;">cin</span>, entNum<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> table<span style="color: #000040;">-</span><span style="color: #000080;">></span><span style="color: #0000dd;">remove</span><span style="color: #008000;">(</span>entNum<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">4</span><span style="color: #008080;">:</span> <span style="color: #666666;">// show All Records</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">system</span><span style="color: #008000;">(</span><span style="color: #FF0000;">"clear"</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> table<span style="color: #000040;">-</span><span style="color: #000080;">></span>print<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"enter to continue ..."</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> ch <span style="color: #000080;">=</span> std<span style="color: #008080;">::</span><span style="color: #0000dd;">getchar</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">5</span><span style="color: #008080;">:</span> <span style="color: #666666;">// clear All Data</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000dd;">delete</span> table<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> table <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> HashTable<span style="color: #008000;">(</span>n<span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">6</span><span style="color: #008080;">:</span> <span style="color: #666666;">// Exit</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">goto</span> DONE<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> DONE<span style="color: #008080;">:</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000dd;">delete</span> table<span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> credits<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">}</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"> </div></li>
</ol></div>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com8tag:blogger.com,1999:blog-4276715425787171951.post-7592253470743712332009-11-03T10:22:00.000+05:302009-11-03T10:22:12.386+05:30GOOGLE boaststoday morning, i though what is google's opinion about itself. I typed << google >> in google search box and it comes up with this amazingly large number of results.<br />
<br />
Results <b>1</b> - <b>10</b> of about <b>2,000,000,000</b> for <b>google</b>. (<b>0.06</b> seconds)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/_4Mr9PcctaeY/Su-1yt4FpcI/AAAAAAAAAGw/Bp1rx7lQePc/s1600-h/desktop1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/_4Mr9PcctaeY/Su-1yt4FpcI/AAAAAAAAAGw/Bp1rx7lQePc/s640/desktop1.png" /></a><br /></div>
<br />
<br />
then i thought what might be at 101th page of results, when i tried to reach 101th page, it comes up with something unpredictable<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/_4Mr9PcctaeY/Su-2JTdgRWI/AAAAAAAAAG4/5sHbGcsDGv4/s1600-h/desktop2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/_4Mr9PcctaeY/Su-2JTdgRWI/AAAAAAAAAG4/5sHbGcsDGv4/s640/desktop2.png" /></a><br /></div>
<br />
WTF is going on. <br />
I believed that google is the truth and unbiased, but after this scenario, i think even google boasts about itself.<br />
Even though it shows 2billion results for term 'google', it doesn't deliver more than 1000, then what's the point in showing those large numbers on first page.<br />rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com4tag:blogger.com,1999:blog-4276715425787171951.post-22828530773280951992009-10-22T19:18:00.000+05:302009-10-22T19:18:20.883+05:30KDE 4.3.2 ..... awsome !!!!<div style="font-family: "Courier New",Courier,monospace;">
yestarday, i have shifted from ubuntu to kubuntu. I love KDE4.3.2.
I heard KDE team fixed 10,000 bugs from 4.2 release to stabilize 4.3. It's a lot of work and now the KDE is awsome smooth. And it also consumes lot less RAM than Radmond OSes. It's working more smoother for me than ubuntu.<br /></div>
<br />
<div style="color: blue;">
<b><span style="font-family: Georgia,"Times New Roman",serif;">Here's a look of my desktop:</span></b><br /></div>
<div style="color: blue;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/_4Mr9PcctaeY/SuBiVHDjiEI/AAAAAAAAAGg/PoDyNQU4uWQ/s1600-h/desktop.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/_4Mr9PcctaeY/SuBiVHDjiEI/AAAAAAAAAGg/PoDyNQU4uWQ/s640/desktop.png" /></a><br /></div>
<div style="color: blue;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/_4Mr9PcctaeY/SuBijmFYSlI/AAAAAAAAAGo/y6x3Zxbr6U4/s1600-h/desktop1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/_4Mr9PcctaeY/SuBijmFYSlI/AAAAAAAAAGo/y6x3Zxbr6U4/s640/desktop1.png" /></a><br /></div>
<div style="color: blue;">
<b><span style="font-family: Georgia,"Times New Roman",serif;"> </span></b>
<br /></div>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com0tag:blogger.com,1999:blog-4276715425787171951.post-89034486504303966392009-10-20T16:11:00.001+05:302009-10-21T10:20:32.409+05:30MacPaint source ....... where ?<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/_4Mr9PcctaeY/St6S-zGMdUI/AAAAAAAAAD4/Z3opEK30OVY/s1600-h/makpaint.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/_4Mr9PcctaeY/St6S-zGMdUI/AAAAAAAAAD4/Z3opEK30OVY/s320/makpaint.gif" /></a><br /></div>
<br />
yesterday, i was reading <i>Coders at work</i> in which donald knuth
pointed out that MacPaint is the one of the best code ever written and
it's source code is donated to Computer History Museum (CHM). So, today
i am searching for it's source code. But after 4 hours i still can't
find it anywhere on the net. CHM website has a page for this, but no
link for downloading source code. It turns out that it is due to legal
issues. Apple still didn't provide rights to CHM for MacPaint. So, i
have to wait ..............................<br />
<br />
<div>
link at CHM:<br />
</div>
<div style="margin-left: 80px;">
<a href="http://www.computerhistory.org/collections/accession/X2948.2005"><i>http:<cite>www.computerhistory.org/collections/acce<wbr></wbr>ssion/X2948.2005 </cite></i></a><br />
</div>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com2tag:blogger.com,1999:blog-4276715425787171951.post-1196355521844003872009-10-13T15:37:00.001+05:302009-10-13T15:41:21.983+05:30Computer Science Education: Where Are the Software Engineers of Tomorrow?<span class="ctAbstract">It is our view that Computer Science (CS)
education is neglecting basic skills, in particular in the areas of
programming and formal methods. We consider that the general adoption
of Java as a first programming language is in part responsible for this
decline. We examine briefly the set of programming skills that should
be part of every software professional’s repertoire.</span><hr />
<div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
It
is all about programming! Over the last few years we have noticed
worrisome trends in CS education. The following represents a summary of
those trends:<br /></div>
<div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<br /></div>
<ol>
<li>Mathematics requirements in CS programs are shrinking.</li>
<li>The
development of programming skills in several languages is giving way to
cookbook approaches using large libraries and special-purpose packages.</li>
<li>The
resulting set of skills is insufficient for today’s software industry
(in particular for safety and security purposes) and, unfortunately,
matches well what the outsourcing industry can offer. We are training
easily replaceable professionals.</li>
</ol>
<div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
These
trends are visible in the latest curriculum recommendations from the
Association for Computing Machinery (ACM). Curriculum 2005 does not
mention mathematical prerequisites at all, and it mentions only one
course in the theory of programming languages [1].<br /></div>
<div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
We
have seen these developments from both sides: As faculty members at New
York University for decades, we have regretted the introduction of Java
as a first language of instruction for most computer science majors. We
have seen how this choice has weakened the formation of our students,
as reflected in their performance in systems and architecture courses.
As founders of a company that specializes in Ada programming tools for
mission-critical systems, we find it harder to recruit qualified
applicants who have the right foundational skills. We want to advocate
a more rigorous formation, in which formal methods are introduced early
on, and programming languages play a central role in CS education.<br /></div>
<span class="ctSectionTitle">Formal Methods and Software Construction</span><br /><div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
Formal
techniques for proving the correctness of programs were an extremely
active subject of research 20 years ago. However, the methods (and the
hardware) of the time prevented these techniques from becoming
widespread, and as a result they are more or less ignored by most CS
programs. This is unfortunate because the techniques have evolved to
the point that they can be used in large-scale systems and can
contribute substantially to the reliability of these systems. A case in
point is the use of SPARK in the re-engineering of the ground-based air
traffic control system in the United Kingdom (see a description of
iFACTS – Interim Future Area Control Tools Support, at
<www.nats.co.uk 90="" article="">). SPARK is a subset of Ada augmented
with assertions that allow the designer to prove important properties
of a program: termination, absence of run-time exceptions, finite
memory usage, etc. [2]. It is obvious that this kind of design and
analysis methodology (dubbed Correctness by Construction) will add
substantially to the reliability of a system whose design has involved
SPARK from the beginning. However, PRAXIS, the company that developed
SPARK and which is designing iFACTS, finds it hard to recruit people
with the required mathematical competence (and this is present even in
the United Kingdom, where formal methods are more widely taught and
used than in the United States).</www.nats.co.uk><br /></div>
<div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
Another
formal approach to which CS students need exposure is model checking
and linear temporal logic for the design of concurrent systems. For a
modern discussion of the topic, which is central to mission-critical
software, see [3].<br /></div>
<div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
Another
area of computer science which we find neglected is the study of
floating-point computations. At New York University, a course in
numerical methods and floating-point computing used to be required, but
this requirement was dropped many years ago, and now very few students
take this course. The topic is vital to all scientific and engineering
software and is semantically delicate. One would imagine that it would
be a required part of all courses in scientific computing, but these
often take MatLab to be the universal programming tool and ignore the
topic altogether.<br /></div>
<span class="ctSectionTitle">The Pitfalls of Java as a First Programming Language</span><br /><div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
Because
of its popularity in the context of Web applications and the ease with
which beginners can produce graphical programs, Java has become the
most widely used language in introductory programming courses. We
consider this to be a misguided attempt to make programming more fun,
perhaps in reaction to the drop in CS enrollments that followed the
dot-com bust. What we observed at New York University is that the Java
programming courses did not prepare our students for the first course
in systems, much less for more advanced ones. Students found it hard to
write programs that did not have a graphic interface, had no feeling
for the relationship between the source program and what the hardware
would actually do, and (most damaging) did not understand the semantics
of pointers at all, which made the use of C in systems programming very
challenging.<br /></div>
<div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
Let
us propose the following principle: The irresistible beauty of
programming consists in the reduction of complex formal processes to a
very small set of primitive operations. Java, instead of exposing this
beauty, encourages the programmer to approach problem-solving like a
plumber in a hardware store: by rummaging through a multitude of
drawers (i.e. packages) we will end up finding some gadget (i.e. class)
that does roughly what we want. How it does it is not interesting! The
result is a student who knows how to put a simple program together, but
does not know how to program. A further pitfall of the early use of
Java libraries and frameworks is that it is impossible for the student
to develop a sense of the run-time cost of what is written because it
is extremely hard to know what any method call will eventually execute.
A lucid analysis of the problem is presented in [4].<br /></div>
<div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
We
are seeing some backlash to this approach. For example, Bjarne
Stroustrup reports from Texas A & M University that the industry is
showing increasing unhappiness with the results of this approach.
Specifically, he notes the following:<br /></div>
<div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<br /></div>
<blockquote>
I
have had a lot of complaints about that [the use of Java as a first
programming language] from industry, specifically from AT&T, IBM,
Intel, Bloomberg, NI, Microsoft, Lockheed-Martin, and more. [5] </blockquote>
<div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
He noted in a private discussion on this topic, reporting the following:<br /></div>
<div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<br /></div>
<blockquote>
It
[Texas A&M] did [teach Java as the first language]. Then I started
teaching C++ to the electrical engineers and when the EE students
started to out-program the CS students, the CS department switched to
C++. [5] </blockquote>
<div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
It
will be interesting to see how many departments follow this trend. At
AdaCore, we are certainly aware of many universities that have adopted
Ada as a first language because of similar concerns.<br /></div>
<span class="ctSectionTitle">A Real Programmer Can Write in Any Language (C, Java, Lisp, Ada)</span><br /><div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
Software
professionals of a certain age will remember the slogan of old-timers
from two generations ago when structured programming became the rage:
Real programmers can write Fortran in any language. The slogan is a
reminder of how thinking habits of programmers are influenced by the
first language they learn and how hard it is to shake these habits if
you do all your programming in a single language. Conversely, we want
to say that a competent programmer is comfortable with a number of
different languages and that the programmer must be able to use the
mental tools favored by one of them, even when programming in another.
For example, the user of an imperative language such as Ada or C++ must
be able to write in a functional style, acquired through practice with
Lisp and ML<sup>1</sup>, when manipulating recursive structures. This
is one indication of the importance of learning in-depth a number of
different programming languages. What follows summarizes what we think
are the critical contributions that well-established languages make to
the mental tool-set of real programmers. For example, a real programmer
should be able to program inheritance and dynamic dispatching in C,
information hiding in Lisp, tree manipulation libraries in Ada, and
garbage collection in anything but Java. The study of a wide variety of
languages is, thus, indispensable to the well-rounded programmer.<br /></div>
<span class="ctSubsectionTitle">Why C Matters</span><br /><div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
C
is the low-level language that everyone must know. It can be seen as a
portable assembly language, and as such it exposes the underlying
machine and forces the student to understand clearly the relationship
between software and hardware. Performance analysis is more
straightforward, because the cost of every software statement is clear.
Finally, compilers (GCC for example) make it easy to examine the
generated assembly code, which is an excellent tool for understanding
machine language and architecture.<br /></div>
<span class="ctSubsectionTitle">Why C++ Matters</span><br /><div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
C++
brings to C the fundamental concepts of modern software engineering:
encapsulation with classes and namespaces, information hiding through
protected and private data and operations, programming by extension
through virtual methods and derived classes, etc. C++ also pushes
storage management as far as it can go without full-blown garbage
collection, with constructors and destructors.<br /></div>
<span class="ctSubsectionTitle">Why Lisp Matters</span><br /><div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
Every
programmer must be comfortable with functional programming and with the
important notion of referential transparency. Even though most
programmers find imperative programming more intuitive, they must
recognize that in many contexts that a functional, stateless style is
clear, natural, easy to understand, and efficient to boot.<br /></div>
<div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
An
additional benefit of the practice of Lisp is that the program is
written in what amounts to abstract syntax, namely the internal
representation that most compilers use between parsing and code
generation. Knowing Lisp is thus an excellent preparation for any
software work that involves language processing.<br /></div>
<div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
Finally,
Lisp (at least in its lean Scheme incarnation) is amenable to a very
compact self-definition. Seeing a complete Lisp interpreter written in
Lisp is an intellectual revelation that all computer scientists should
experience.<br /></div>
<span class="ctSubsectionTitle">Why Java Matters</span><br /><div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
Despite
our comments on Java as a first or only language, we think that Java
has an important role to play in CS instruction. We will mention only
two aspects of the language that must be part of the real programmer’s
skill set:<br /></div>
<div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<br /></div>
<ol>
<li>An understanding of concurrent programming (for which threads provide a basic low-level model).</li>
<li>Reflection,
namely the understanding that a program can be instrumented to examine
its own state and to determine its own behavior in a dynamically
changing environment.</li>
</ol>
<span class="ctSubsectionTitle">Why Ada Matters</span><br /><div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
Ada
is the language of software engineering par excellence. Even when it is
not the language of instruction in programming courses, it is the
language chosen to teach courses in software engineering. This is
because the notions of strong typing, encapsulation, information
hiding, concurrency, generic programming, inheritance, and so on, are
embodied in specific features of the language. From our experience and
that of our customers, we can say that a real programmer writes Ada in
any language. For example, an Ada programmer accustomed to Ada’s
package model, which strongly separates specification from
implementation, will tend to write C in a style where well-commented
header files act in somewhat the same way as package specs in Ada. The
programmer will include bounds checking and consistency checks when
passing mutable structures between subprograms to mimic the
strong-typing checks that Ada mandates [6]. She will organize
concurrent programs into tasks and protected objects, with well-defined
synchronization and communication mechanisms.<br /></div>
<div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
The
concurrency features of Ada are particularly important in our age of
multi-core architectures. We find it surprising that these
architectures should be presented as a novel challenge to software
design when Ada had well-designed mechanisms for writing safe,
concurrent software 30 years ago.<br /></div>
<span class="ctSectionTitle">Programming Languages Are Not the Whole Story</span><br /><div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
A
well-rounded CS curriculum will include an advanced course in
programming languages that covers a wide variety of languages, chosen
to broaden the understanding of the programming process, rather than to
build a résumé in perceived hot languages. We are somewhat dismayed to
see the popularity of scripting languages in introductory programming
courses. Such languages (Javascript, PHP, Atlas) are indeed popular
tools of today for Web applications. Such languages have all the
pedagogical defaults that we ascribe to Java and provide no opportunity
to learn algorithms and performance analysis. Their absence of strong
typing leads to a trial-and-error programming style and prevents
students from acquiring the discipline of separating design of
interfaces from specifications.<br /></div>
<div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
However,
teaching the right languages alone is not enough. Students need to be
exposed to the tools to construct large-scale reliable programs, as we
discussed at the start of this article. Topics of relevance are
studying formal specification methods and formal proof methodologies,
as well as gaining an understanding of how high-reliability code is
certified in the real world. When you step into a plane, you are
putting your life in the hands of software which had better be totally
reliable. As a computer scientist, you should have some knowledge of
how this level of reliability is achieved. In this day and age, the
fear of terrorist cyber attacks have given a new urgency to the
building of software that is not only bug free, but is also immune from
malicious attack. Such high-security software relies even more
extensively on formal methodologies, and our students need to be
prepared for this new world.<br /></div>
<span class="ctSectionTitle">References</span><br /><div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<br /></div>
<ol>
<li>Joint
Taskforce for Computing Curricula. “Computing Curricula 2005: The
Overview Report.” ACM/AIS/ IEEE, 2005 <www.acm.org cc2005-march06="" curric_vols="" education="" final.pdf="">.</www.acm.org></li>
<li>Barnes, John.<i> High Integrity Ada: The Spark Approach</i>. Addison-Wesley, 2003. </li>
<li>Ben-Ari, M.<i> Principles of Concurrent and Distributed Programming</i>. 2nd ed. Addison-Wesley, 2006. </li>
<li>Mitchell,
Nick, Gary Sevitsky, and Harini Srinivasan. “The Diary of a Datum: An
Approach to Analyzing Runtime Complexity in Framework-Based
Applications.” Workshop on Library-Centric Software Design,
Object-Oriented Programming, Systems, Languages, and Applications, San
Diego, CA, 2005.</li>
<li>Stroustrup, Bjarne. Private communication. Aug. 2007.</li>
<li>Holzmann Gerard J. “The Power of Ten – Rules for Developing Safety Critical Code.”<i> IEEE Computer </i>June 2006: 93-95. </li>
</ol>
<span class="ctSectionTitle">Note</span><br /><div xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<br /></div>
<ol>
<li>Several
programming language and system names have evolved from acronyms whose
formal spellings are no longer considered applicable to the current
names for which they are readily known. ML, Lisp, GCC, PHP, and SPARK
fall under this category.</li>
</ol>
<hr />
<span class="ctSectionTitle">About the Authors</span><br /><img align="center" alt="Dr. Robert B.K. Dewar" border="0" height="158" src="http://www.stsc.hill.af.mil/CrossTalk/2008/01/0801Dewar.jpg" width="134" />
<strong xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">Robert B.K. Dewar, Ph.D., </strong>is
president of AdaCore and a professor emeritus of computer science at
New York University. He has been involved in the design and
implementation of Ada since 1980 as a distinguished reviewer, a member
of the Ada Rapporteur group, and the chief architect of Gnu Ada
Translator. He was a member of the Algol68 committee and is the
designer and implementor of Spitbol. Dewar lectures widely on
programming languages, software methodologies, safety and security, and
on intellectual property rights. He has a doctorate in chemistry from
the University of Chicago. <br /><br />AdaCore<br />104 Fifth AVE 15th FL<br />New York, NY 10011<br />
Phone: (212) 620-7300 ext. 100<br />
Fax: (212) 807-0162<br />
E-mail: <a href="mailto:%20dewar@adacore.com"> dewar@adacore.com</a><br />
<br clear="all" /><hr />
<img align="center" alt="Dr. Edmond Schonberg" border="0" height="158" src="http://www.stsc.hill.af.mil/CrossTalk/2008/01/0801Schonberg.jpg" width="134" />
<strong xmlns:msn="http://www.stsc.hill.af.mil/msn" xmlns:xs="http://www.w3.org/2001/XMLSchema">Edmond Schonberg, Ph.D.,</strong>
is vice-president of AdaCore and a professor emeritus of computer
science at New York University. He has been involved in the
implementation of Ada since 1981. With Robert Dewar and other
collaborators, he created the first validated implementation of Ada83,
the first prototype compiler for Ada9X, and the first full
implementation of Ada2005. Schonberg has a doctorate in physics from
the University of Chicago. <br /><br />AdaCore<br />104 Fifth AVE 15th FL<br />New York, NY 10011<br />
E-mail: <a href="mailto:%20schonberg@adacore.com"> schonberg@adacore.com</a>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com0tag:blogger.com,1999:blog-4276715425787171951.post-7056771448924524812009-10-08T15:18:00.000+05:302009-10-08T15:18:06.916+05:30An inteview with Brian Kernighan (october 6, 2009)<div class="storybody">
<b>You maintain you had no part in the birth of C, but do you think the
language would have been as successful as it has been without the book?</b>
<br /></div>
<div class="storybody">
<b>Brian Kernighan:</b> The word is not
‘maintained’; it's ‘stated accurately’. C is entirely Dennis Ritchie's
work. C would have done just fine on its own, since as a language it
achieved a perfect balance among efficiency, expressiveness, and power.
The book probably helped, though I think more in spreading the language
early on than in its ultimate acceptance. Of course, it helped
enormously to have Dennis as co-author, for his expertise and his
writing.
<br /></div>
<div class="storybody">
<b>In the ten years since you launched <i>The Practice of Programming</i>,
a separate book written with Rob Pike, has the way programmers operate
changed enough for you to consider amending any parts of the
publication? </b>
<br /></div>
<div class="storybody">
Programming today depends more and more on
combining large building blocks and less on detailed logic of little
things, though there's certainly enough of that as well. A typical
programmer today spends a lot of time just trying to figure out what
methods to call from some giant package and probably needs some kind of
IDE like Eclipse or XCode to fill in the gaps. There are more languages
in regular use and programs are often distributed combinations of
multiple languages. All of these facts complicate life, though it's
possible to build quite amazing systems quickly when everything goes
right. I think that the advice on detailed topics in <i>The Practice of Programming</i>
is sound and will always be — one has to find the right algorithms and
data structures, one has to test and debug and worry about performance,
and there are general issues like good notation that will always make
life much better. But it's not clear to me or to Rob that we have
enough new good ideas for a new book, at least at the moment.
<br /></div>
<div class="storybody">
<b>What advice do you have for young programmers starting out? Would you recommend a grounding in Cobol like you had, for example?</b>
<br /></div>
<div class="storybody">
Every language teaches you something, so
learning a language is never wasted, especially if it's different in
more than just syntactic trivia. One of Alan Perlis's many wise and
witty epigrams says, "A language that doesn't affect the way you think
about programming is not worth knowing". On the other hand, I would not
suggest Cobol as a primary focus for most people today — I learned it
as part of a summer job and long ago, not because it taught me
something new (though it did that as well). No matter what, the way to
learn to program is to write code, and rewrite it, and see it used, and
rewrite again. Reading other people's code is invaluable as well. Of
course all of these assume that the code is good; I don't see a lot of
benefit in reading a lot of bad code, other than to learn what to
avoid, and one should, of course, not write bad code oneself. That's
easier said than done, which is why I stress rewriting.<br /></div>
<div class="storybody">
<b>Who would you consider to be the icons of the programming world?</b>
<br /></div>
<div class="storybody">
For purely parochial reasons, I think of
people who I know or whose work I know well. Ken Thompson and Dennis
Ritchie changed my life and yours; we would not be having this
conversation without them. People who created major languages would
also fall into that camp, for instance we all regularly use languages
created by <a href="http://www.computerworld.com.au/article/250514/-z_programming_languages_c" target="_blank">Bjarne Stroustrup</a>, <a href="http://www.computerworld.com.au/article/25910/interview_gosling_java_tools_his_move_mac" target="_blank">James Gosling</a>, <a href="http://www.computerworld.com.au/article/270267/-z_programming_languages_perl" target="_blank">Larry Wall</a>, and <a href="http://www.computerworld.com.au/article/255835/-z_programming_languages_python" target="_blank">Guido von Rossum</a>.
And of course there are super-icons like Don Knuth and Fred Brooks. But
this is a personal list; there are many others whose work has been
influential, and your list would surely differ.<br /></div>
<div class="storybody">
<b>Bell Labs has produced some of the most influential figures in the
world as far as IT goes — does it still maintain its relevance in your
view? What could it do to better its acclaimed past?</b>
<br /></div>
<div class="storybody">
Bell Labs was an astonishing place for many
decades, though it fell on somewhat hard times during the telecom
meltdown some years ago, as its corporate owner had to cope with
shrinking markets. There are great people at Bell Labs but the
operation is much smaller than it used to be, which reduces the chance
of a big impact, though certainly it can still happen — all it takes is
one or two people with a good idea.
<br /></div>
<div class="storybody">
<b>What are you working on at the moment? Can we expect any new books or work on languages?</b>
<br /></div>
<div class="storybody">
I seem to get totally wrapped up in teaching
and working with students during the school year. During the summer I
try to spend time in the real world, writing code for therapy and
perhaps for some useful purpose. This is fun but so far it hasn't led
to any book, though ideas are percolating. I'm still very interested in
domain-specific languages and, more generally, in tools that make it
easier to write code. And it sometimes seems like some of the old Unix
command line languages for special purposes might have a second life in
web pages. So I play with these from time to time, or entice some
student into exploring a half-baked idea for a semester.<br /></div>
<div class="storybody">
<b>You've been around the development of some of
the formative influences on the Internet such as UNIX, what do you see
as the driving influences of contemporary computing and the way the
world connects?</b>
<br /></div>
<div class="storybody">
For better or worse, the driving influence
today seems to be to get something up and running and used via the
Internet, as quickly as possible. A good idea, however simple in
retrospect, can give one fame and fortune (witness Google, Facebook,
Twitter, and any number of others). But this only works because there
is infrastructure: open source software like Unix/Linux and GNU tools
and web libraries, dirt-cheap hardware, and essentially free
communications. We're seeing an increase in scalable systems as well,
like Amazon's web services, where one can start very small and grow
rapidly and without real limits as the need arises. It's starting to
look like the Multics idea of an information utility.
<br /></div>
<div class="storybody">
<b>AWK and AMPL languages are two you have
been involved in developing. Are there any languages you would have
liked to have helped develop?</b>
<br /></div>
<div class="storybody">
Well, it's always nice to have been part of a
successful project, so naturally I would like to have helped with
everything good. But I've been quite lucky in the handful that I was
involved in. Most of that comes from having first-rate collaborators (<a href="http://www.computerworld.com.au/article/216844/-z_programming_languages_awk" target="_blank">Al Aho</a> and Peter Weinberger for AWK and Bob Fourer and Dave Gay for AMPL).
<br /></div>
<div class="storybody">
<b>Which companies/individuals would you point to as doing great things for the society at present through computer sciences?</b>
<br /></div>
<div class="storybody">
I might single out Bill and Melinda Gates for
their foundation, made possible by the great success of Microsoft.
Their charitable work is aimed at tough but potentially solvable
problems and operates on a scale that few others can approach. After
that, one might name Google, which has made so much information so
readily accessible; that access has changed the world greatly and is
likely to continue to do so.
<br /></div>
<div class="storybody">
<b>What are you views on the following languages: Perl, Java, and Ruby?</b>
<br /></div>
<div class="storybody">
I use Java some; it's the standard language
for introductory computing at Princeton and lots of other places. I
find it bulky and verbose but it flows pretty smoothly once I get
going. I don't use Perl much at this point — it's been replaced by
Python in my personal working set — but no other language matches the
amount of computation that can be packed into so few characters. I have
not written much Ruby; it clearly has a lot of appeal and some
intriguing ideas, but so far when I have to write a program quickly
some other more familiar language gets used just to get the job done.
But one of these days, I'll add Ruby to the list.
<br /></div>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com0tag:blogger.com,1999:blog-4276715425787171951.post-27775612578710479482009-10-06T10:32:00.006+05:302009-10-06T16:25:45.103+05:30wheel rotating on a plane (sunanda madam's assignment)<object height="340" width="560">
<param name="movie" value="http://www.youtube.com/v/RGJFf9vwLa4&hl=en&fs=1&">
</param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/RGJFf9vwLa4&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed>
</object>
<br />
<br />
<div style="background-color: yellow; color: blue; font-family: 'Courier New',Courier,monospace;">
<span style="font-size: large;"><b>FILE : rrc.cpp</b></span> <br />
</div>
<div class="cpp" style="background-color: #f0f0f0; border-bottom: #d0d0d0 1px solid; border-left: #d0d0d0 1px solid; border-right: #d0d0d0 1px solid; border-top: #d0d0d0 1px solid; color: #000066; font-family: monospace;">
<span style="color: red; font-style: italic;">/*<br /> * rrc.cpp<br /> *<br /> * Copyright 2009 Rooparam Choudhary <rooparambhakar@gmail.com><br /> *<br /> * This program is free software; you can redistribute it and/or modify<br /> * it under the terms of the GNU General Public License as published by<br /> * the Free Software Foundation; either version 2 of the License, or<br /> * (at your option) any later version.<br /> *<br /> * This program is distributed in the hope that it will be useful,<br /> * but WITHOUT ANY WARRANTY; without even the implied warranty of<br /> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br /> * GNU General Public License for more details.<br /> *<br /> * You should have received a copy of the GNU General Public License<br /> * along with this program; if not, write to the Free Software<br /> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,<br /> * MA 02110-1301, USA.<br /> */</span><br />
<span style="color: #339900;">#include <graphics.h></span><br />
<span style="color: #339900;">#include <math.h></span><br />
<br />
<span style="color: blue;">typedef</span> <span style="color: blue;">float</span> matrix3x3<span style="color: green;">[</span>3<span style="color: green;">]</span><span style="color: green;">[</span>3<span style="color: green;">]</span><span style="color: teal;">;</span><br />
<span style="color: blue;">typedef</span> <span style="color: blue;">float</span> vector<span style="color: green;">[</span>3<span style="color: green;">]</span><span style="color: teal;">;</span><br />
<br />
<br />
<span style="color: red; font-style: italic;">/* -------- Public Interface ------------ */</span><br />
<span style="color: blue;">static</span> <span style="color: blue;">int</span> _WIDTH <span style="color: navy;">=</span> <span style="color: #0000dd;">640</span><span style="color: teal;">;</span> <span style="color: blue;">static</span> <span style="color: blue;">int</span> _HEIGHT <span style="color: navy;">=</span> <span style="color: #0000dd;">480</span><span style="color: teal;">;</span><br />
<span style="color: blue;">static</span> <span style="color: blue;">int</span> _CX <span style="color: navy;">=</span> <span style="color: #0000dd;">320</span><span style="color: teal;">;</span> <span style="color: blue;">static</span> <span style="color: blue;">int</span> _CY <span style="color: navy;">=</span> <span style="color: #0000dd;">240</span><span style="color: teal;">;</span> <span style="color: #666666;">// CENTER OF COORDINATES</span><br />
<span style="color: blue;">static</span> <span style="color: blue;">int</span> _COLOR <span style="color: navy;">=</span> BLACK<span style="color: teal;">;</span><br />
<span style="color: blue;">static</span> vector _DOT<span style="color: teal;">;</span><br />
<span style="color: blue;">static</span> matrix3x3 _M<span style="color: teal;">;</span><br />
<span style="color: blue;">static</span> <span style="color: blue;">int</span> _TRANS <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> <span style="color: #666666;">// whether to use transformation matrix in pixel drawing</span><br />
<span style="color: #666666;">// 0: false 1: true</span><br />
<br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> SetToIdentity<span style="color: green;">(</span>matrix3x3 X<span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">// Converts X to indentity matrix</span><br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> Transform<span style="color: green;">(</span>matrix3x3 X, vector P<span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">// P = X.P</span><br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> mul<span style="color: green;">(</span>matrix3x3 Left, matrix3x3 right<span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">// [right] = [Left].[right]</span><br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> Translate<span style="color: green;">(</span>matrix3x3 X, <span style="color: blue;">int</span> tx, <span style="color: blue;">int</span> ty<span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">// X = [Tranlation matrix].X </span><br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> Rotate<span style="color: green;">(</span>matrix3x3 X, <span style="color: blue;">float</span> theta<span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">// X = [Rotation Matrix].X</span><br />
<br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> setPixel<span style="color: green;">(</span><span style="color: blue;">int</span> x, <span style="color: blue;">int</span> y<span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">// (x, y) are in screen coordinates</span><br />
<span style="color: #666666;">// to optimize, shift transformation operations from setPixel to line_r.</span><br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> line_r<span style="color: green;">(</span><span style="color: blue;">int</span> x0, <span style="color: blue;">int</span> y0, <span style="color: blue;">int</span> x1, <span style="color: blue;">int</span> y1, <span style="color: blue;">const</span> <span style="color: blue;">int</span> color <span style="color: navy;">=</span> <span style="color: #000040;">-</span>1<span style="color: green;">)</span><span style="color: teal;">;</span> <br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> circle_r<span style="color: green;">(</span><span style="color: blue;">int</span> xc, <span style="color: blue;">int</span> yc, <span style="color: blue;">const</span> <span style="color: blue;">int</span> radius, <span style="color: blue;">const</span> <span style="color: blue;">int</span> color <span style="color: navy;">=</span> <span style="color: #000040;">-</span>1<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> ellipse_r<span style="color: green;">(</span><span style="color: blue;">int</span> xc, <span style="color: blue;">int</span> yc, <span style="color: blue;">int</span> rx, <span style="color: blue;">int</span> ry, <span style="color: blue;">const</span> <span style="color: blue;">int</span> color <span style="color: navy;">=</span> <span style="color: #000040;">-</span>1<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<br />
<span style="color: red; font-style: italic;">/* -------------------------------------- */</span><br />
<br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> Transform<span style="color: green;">(</span>matrix3x3 X, vector P<span style="color: green;">)</span> <span style="color: green;">{</span><br />
vector T<span style="color: teal;">;</span><br />
<span style="color: blue;">for</span><span style="color: green;">(</span><span style="color: blue;">int</span> i<span style="color: navy;">=</span><span style="color: #0000dd;">0</span><span style="color: teal;">;</span> i<span style="color: navy;"><</span><span style="color: #0000dd;">3</span><span style="color: teal;">;</span> <span style="color: #000040;">++</span>i<span style="color: green;">)</span> <span style="color: green;">{</span><br />
T<span style="color: green;">[</span>i<span style="color: green;">]</span> <span style="color: navy;">=</span> <span style="color: purple;">0.0f</span><span style="color: teal;">;</span><br />
<span style="color: blue;">for</span><span style="color: green;">(</span><span style="color: blue;">int</span> j <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> j<span style="color: navy;"><</span><span style="color: #0000dd;">3</span><span style="color: teal;">;</span> <span style="color: #000040;">++</span>j<span style="color: green;">)</span> <span style="color: green;">{</span><br />
T<span style="color: green;">[</span>i<span style="color: green;">]</span> <span style="color: #000040;">+</span><span style="color: navy;">=</span> X<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>j<span style="color: green;">]</span><span style="color: #000040;">*</span>P<span style="color: green;">[</span>j<span style="color: green;">]</span><span style="color: teal;">;</span><br />
<span style="color: green;">}</span><br />
<span style="color: green;">}</span><br />
P<span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: navy;">=</span> T<span style="color: green;">[</span>0<span style="color: green;">]</span><span style="color: teal;">;</span><br />
P<span style="color: green;">[</span>1<span style="color: green;">]</span> <span style="color: navy;">=</span> T<span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: teal;">;</span><br />
P<span style="color: green;">[</span>2<span style="color: green;">]</span> <span style="color: navy;">=</span> T<span style="color: green;">[</span>2<span style="color: green;">]</span><span style="color: teal;">;</span><br />
<span style="color: green;">}</span><br />
<br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> SetToIdentity<span style="color: green;">(</span>matrix3x3 X<span style="color: green;">)</span> <span style="color: green;">{</span><br />
<span style="color: blue;">for</span><span style="color: green;">(</span><span style="color: blue;">int</span> i<span style="color: navy;">=</span><span style="color: #0000dd;">0</span><span style="color: teal;">;</span> i<span style="color: navy;"><</span><span style="color: #0000dd;">3</span><span style="color: teal;">;</span> <span style="color: #000040;">++</span>i<span style="color: green;">)</span> <span style="color: green;">{</span><br />
<span style="color: blue;">for</span><span style="color: green;">(</span><span style="color: blue;">int</span> j<span style="color: navy;">=</span><span style="color: #0000dd;">0</span><span style="color: teal;">;</span> j<span style="color: navy;"><</span><span style="color: #0000dd;">3</span><span style="color: teal;">;</span> <span style="color: #000040;">++</span>j<span style="color: green;">)</span> <span style="color: green;">{</span><br />
X<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>j<span style="color: green;">]</span> <span style="color: navy;">=</span> <span style="color: green;">(</span><span style="color: blue;">float</span><span style="color: green;">)</span><span style="color: green;">(</span>i<span style="color: navy;">==</span>j<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: green;">}</span><br />
<span style="color: green;">}</span><br />
<span style="color: green;">}</span><br />
<br />
<br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> mul<span style="color: green;">(</span>matrix3x3 Left, matrix3x3 right<span style="color: green;">)</span> <span style="color: green;">{</span> <span style="color: #666666;">// right's content will be changed</span><br />
matrix3x3 T<span style="color: teal;">;</span> <span style="color: #666666;">// new matrix</span><br />
<span style="color: blue;">for</span><span style="color: green;">(</span><span style="color: blue;">int</span> i<span style="color: navy;">=</span><span style="color: #0000dd;">0</span><span style="color: teal;">;</span> i<span style="color: navy;"><</span><span style="color: #0000dd;">3</span><span style="color: teal;">;</span> <span style="color: #000040;">++</span>i<span style="color: green;">)</span> <span style="color: green;">{</span><br />
<span style="color: blue;">for</span><span style="color: green;">(</span><span style="color: blue;">int</span> j<span style="color: navy;">=</span><span style="color: #0000dd;">0</span><span style="color: teal;">;</span> j<span style="color: navy;"><</span><span style="color: #0000dd;">3</span><span style="color: teal;">;</span> <span style="color: #000040;">++</span>j<span style="color: green;">)</span> <span style="color: green;">{</span><br />
T<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>j<span style="color: green;">]</span> <span style="color: navy;">=</span> <span style="color: purple;">0.0f</span><span style="color: teal;">;</span><br />
<span style="color: blue;">for</span><span style="color: green;">(</span><span style="color: blue;">int</span> k<span style="color: navy;">=</span><span style="color: #0000dd;">0</span><span style="color: teal;">;</span> k<span style="color: navy;"><</span><span style="color: #0000dd;">3</span><span style="color: teal;">;</span> <span style="color: #000040;">++</span>k<span style="color: green;">)</span><br />
T<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>j<span style="color: green;">]</span> <span style="color: #000040;">+</span><span style="color: navy;">=</span> Left<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>k<span style="color: green;">]</span> <span style="color: #000040;">*</span> right<span style="color: green;">[</span>k<span style="color: green;">]</span><span style="color: green;">[</span>j<span style="color: green;">]</span><span style="color: teal;">;</span><br />
<span style="color: green;">}</span><br />
<span style="color: green;">}</span><br />
<br />
<span style="color: #666666;">// copy T to right</span><br />
<span style="color: blue;">for</span><span style="color: green;">(</span><span style="color: blue;">int</span> i<span style="color: navy;">=</span><span style="color: #0000dd;">0</span><span style="color: teal;">;</span> i <span style="color: navy;"><</span> <span style="color: #0000dd;">3</span><span style="color: teal;">;</span> <span style="color: #000040;">++</span>i<span style="color: green;">)</span><br />
<span style="color: blue;">for</span><span style="color: green;">(</span><span style="color: blue;">int</span> j<span style="color: navy;">=</span><span style="color: #0000dd;">0</span><span style="color: teal;">;</span> j <span style="color: navy;"><</span> <span style="color: #0000dd;">3</span><span style="color: teal;">;</span> <span style="color: #000040;">++</span>j<span style="color: green;">)</span><br />
right<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>j<span style="color: green;">]</span> <span style="color: navy;">=</span> T<span style="color: green;">[</span>i<span style="color: green;">]</span><span style="color: green;">[</span>j<span style="color: green;">]</span><span style="color: teal;">;</span><br />
<span style="color: green;">}</span><br />
<br />
<span style="color: red; font-style: italic;">/* [Tranlation matrix].X */</span><br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> Translate<span style="color: green;">(</span>matrix3x3 X, <span style="color: blue;">int</span> tx, <span style="color: blue;">int</span> ty<span style="color: green;">)</span> <span style="color: green;">{</span><br />
matrix3x3 A1<span style="color: teal;">;</span><br />
SetToIdentity<span style="color: green;">(</span>A1<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<br />
A1<span style="color: green;">[</span>0<span style="color: green;">]</span><span style="color: green;">[</span>2<span style="color: green;">]</span> <span style="color: navy;">=</span> tx<span style="color: teal;">;</span><br />
A1<span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: green;">[</span>2<span style="color: green;">]</span> <span style="color: navy;">=</span> ty<span style="color: teal;">;</span><br />
<br />
mul<span style="color: green;">(</span>A1, X<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: green;">}</span><br />
<br />
<span style="color: red; font-style: italic;">/* [Rotation Matrix].X */</span><br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> Rotate<span style="color: green;">(</span>matrix3x3 X, <span style="color: blue;">float</span> theta<span style="color: green;">)</span> <span style="color: green;">{</span><br />
matrix3x3 A1<span style="color: teal;">;</span> <span style="color: #666666;">// rotation matrix</span><br />
SetToIdentity<span style="color: green;">(</span>A1<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<br />
A1<span style="color: green;">[</span>0<span style="color: green;">]</span><span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: navy;">=</span> A1<span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: green;">[</span>1<span style="color: green;">]</span> <span style="color: navy;">=</span> <span style="color: #0000dd;">cos</span><span style="color: green;">(</span>theta<span style="color: green;">)</span><span style="color: teal;">;</span><br />
A1<span style="color: green;">[</span>0<span style="color: green;">]</span><span style="color: green;">[</span>1<span style="color: green;">]</span> <span style="color: navy;">=</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">sin</span><span style="color: green;">(</span>theta<span style="color: green;">)</span><span style="color: teal;">;</span><br />
A1<span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: navy;">=</span> <span style="color: #0000dd;">sin</span><span style="color: green;">(</span>theta<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<br />
mul<span style="color: green;">(</span>A1, X<span style="color: green;">)</span><span style="color: teal;">;</span> <br />
<span style="color: green;">}</span><br />
<br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> setPixel<span style="color: green;">(</span><span style="color: blue;">int</span> x, <span style="color: blue;">int</span> y<span style="color: green;">)</span> <span style="color: green;">{</span><br />
<span style="color: blue;">if</span><span style="color: green;">(</span>_TRANS<span style="color: green;">)</span> <span style="color: green;">{</span><br />
_DOT<span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: navy;">=</span> <span style="color: green;">(</span><span style="color: blue;">float</span><span style="color: green;">)</span><span style="color: green;">(</span>x <span style="color: #000040;">-</span> _CX<span style="color: green;">)</span><span style="color: teal;">;</span><br />
_DOT<span style="color: green;">[</span>1<span style="color: green;">]</span> <span style="color: navy;">=</span> <span style="color: green;">(</span><span style="color: blue;">float</span><span style="color: green;">)</span><span style="color: green;">(</span><span style="color: #000040;">-</span>y <span style="color: #000040;">+</span> _CY<span style="color: green;">)</span><span style="color: teal;">;</span><br />
_DOT<span style="color: green;">[</span>2<span style="color: green;">]</span> <span style="color: navy;">=</span> <span style="color: purple;">1.0f</span><span style="color: teal;">;</span><br />
<br />
Transform<span style="color: green;">(</span>_M, _DOT<span style="color: green;">)</span><span style="color: teal;">;</span><br />
x <span style="color: navy;">=</span> <span style="color: blue;">int</span><span style="color: green;">(</span>_DOT<span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: #000040;">+</span> _CX<span style="color: green;">)</span><span style="color: teal;">;</span> y <span style="color: navy;">=</span> <span style="color: blue;">int</span><span style="color: green;">(</span>_CY <span style="color: #000040;">-</span> _DOT<span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: green;">}</span><br />
putpixel<span style="color: green;">(</span>x, y, _COLOR<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: green;">}</span><br />
<br />
<span style="color: red; font-style: italic;">/*<br /> * line drawing function on the screen<br /> * implements : Bresenhem's Line Drawing Algorithm<br /> * parameters :<br /> * x0, y0 - one end of the line<br /> * x1, y1 - another end of the line<br /> * color - color of line, default value -1 indicates<br /> * we will use last defined color<br /> */</span><br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> line_r<span style="color: green;">(</span><span style="color: blue;">int</span> x0, <span style="color: blue;">int</span> y0, <span style="color: blue;">int</span> x1, <span style="color: blue;">int</span> y1, <span style="color: blue;">const</span> <span style="color: blue;">int</span> color<span style="color: green;">)</span><br />
<span style="color: green;">{</span><br />
<span style="color: blue;">if</span><span style="color: green;">(</span>color <span style="color: #000040;">!</span><span style="color: navy;">=</span> <span style="color: #000040;">-</span>1<span style="color: green;">)</span><br />
_COLOR <span style="color: navy;">=</span> color<span style="color: teal;">;</span><br />
<br />
<span style="color: blue;">int</span> isTRANS <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span><br />
<span style="color: blue;">if</span><span style="color: green;">(</span>_TRANS<span style="color: green;">)</span> <span style="color: green;">{</span><br />
_DOT<span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: navy;">=</span> <span style="color: green;">(</span><span style="color: blue;">float</span><span style="color: green;">)</span>x0<span style="color: teal;">;</span><br />
_DOT<span style="color: green;">[</span>1<span style="color: green;">]</span> <span style="color: navy;">=</span> <span style="color: green;">(</span><span style="color: blue;">float</span><span style="color: green;">)</span>y0<span style="color: teal;">;</span><br />
_DOT<span style="color: green;">[</span>2<span style="color: green;">]</span> <span style="color: navy;">=</span> <span style="color: purple;">1.0f</span><span style="color: teal;">;</span><br />
<br />
Transform<span style="color: green;">(</span>_M, _DOT<span style="color: green;">)</span><span style="color: teal;">;</span><br />
x0 <span style="color: navy;">=</span> <span style="color: green;">(</span><span style="color: blue;">int</span><span style="color: green;">)</span>_DOT<span style="color: green;">[</span>0<span style="color: green;">]</span><span style="color: teal;">;</span> y0 <span style="color: navy;">=</span> <span style="color: green;">(</span><span style="color: blue;">int</span><span style="color: green;">)</span>_DOT<span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: teal;">;</span><br />
<br />
_DOT<span style="color: green;">[</span>0<span style="color: green;">]</span> <span style="color: navy;">=</span> <span style="color: green;">(</span><span style="color: blue;">float</span><span style="color: green;">)</span>x1<span style="color: teal;">;</span><br />
_DOT<span style="color: green;">[</span>1<span style="color: green;">]</span> <span style="color: navy;">=</span> <span style="color: green;">(</span><span style="color: blue;">float</span><span style="color: green;">)</span>y1<span style="color: teal;">;</span><br />
_DOT<span style="color: green;">[</span>2<span style="color: green;">]</span> <span style="color: navy;">=</span> <span style="color: purple;">1.0f</span><span style="color: teal;">;</span><br />
<br />
Transform<span style="color: green;">(</span>_M, _DOT<span style="color: green;">)</span><span style="color: teal;">;</span><br />
x1 <span style="color: navy;">=</span> <span style="color: green;">(</span><span style="color: blue;">int</span><span style="color: green;">)</span>_DOT<span style="color: green;">[</span>0<span style="color: green;">]</span><span style="color: teal;">;</span> y1 <span style="color: navy;">=</span> <span style="color: green;">(</span><span style="color: blue;">int</span><span style="color: green;">)</span>_DOT<span style="color: green;">[</span>1<span style="color: green;">]</span><span style="color: teal;">;</span><br />
<br />
isTRANS <span style="color: navy;">=</span> <span style="color: #0000dd;">1</span><span style="color: teal;">;</span><br />
_TRANS <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span><br />
<span style="color: green;">}</span><br />
<br />
<span style="color: blue;">int</span> inverse <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> <span style="color: #666666;">// 0 : false 1 : true</span><br />
<span style="color: blue;">int</span> sign <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> <span style="color: #666666;">// 0 : y = x 1 : y = -x</span><br />
<br />
<span style="color: red; font-style: italic;">/* ---------------------------------------------------- */</span><br />
inverse <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span><br />
sign <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span><br />
<span style="color: blue;">float</span> m <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span><br />
<span style="color: blue;">int</span> t<span style="color: teal;">;</span><br />
<span style="color: blue;">int</span> infinity <span style="color: navy;">=</span> <span style="color: green;">(</span>x1 <span style="color: navy;">==</span> x0<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<br />
<span style="color: blue;">if</span><span style="color: green;">(</span><span style="color: #000040;">!</span>infinity<span style="color: green;">)</span><br />
m <span style="color: navy;">=</span> <span style="color: green;">(</span>y1<span style="color: #000040;">-</span>y0<span style="color: green;">)</span> <span style="color: #000040;">/</span> <span style="color: green;">(</span><span style="color: blue;">float</span><span style="color: green;">)</span><span style="color: green;">(</span>x1<span style="color: #000040;">-</span>x0<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: blue;">if</span><span style="color: green;">(</span>m <span style="color: navy;"><</span> 0<span style="color: green;">)</span><br />
sign <span style="color: navy;">=</span> <span style="color: #0000dd;">1</span><span style="color: teal;">;</span><br />
<br />
<span style="color: blue;">if</span><span style="color: green;">(</span>infinity <span style="color: #000040;">||</span> <span style="color: #0000dd;">fabs</span><span style="color: green;">(</span>m<span style="color: green;">)</span> <span style="color: navy;">></span> 1<span style="color: green;">)</span> <span style="color: green;">{</span><br />
inverse <span style="color: navy;">=</span> <span style="color: #0000dd;">1</span><span style="color: teal;">;</span><br />
<br />
<span style="color: blue;">if</span><span style="color: green;">(</span>sign<span style="color: green;">)</span><br />
<span style="color: green;">{</span> t <span style="color: navy;">=</span> <span style="color: #000040;">-</span>x0<span style="color: teal;">;</span> x0 <span style="color: navy;">=</span> <span style="color: #000040;">-</span>y0<span style="color: teal;">;</span> y0 <span style="color: navy;">=</span> t<span style="color: teal;">;</span><br />
t <span style="color: navy;">=</span> <span style="color: #000040;">-</span>x1<span style="color: teal;">;</span> x1 <span style="color: navy;">=</span> <span style="color: #000040;">-</span>y1<span style="color: teal;">;</span> y1 <span style="color: navy;">=</span> t<span style="color: teal;">;</span> <span style="color: green;">}</span><br />
<span style="color: blue;">else</span><br />
<span style="color: green;">{</span> t <span style="color: navy;">=</span> x0<span style="color: teal;">;</span> x0 <span style="color: navy;">=</span> y0<span style="color: teal;">;</span> y0 <span style="color: navy;">=</span> t<span style="color: teal;">;</span><br />
t <span style="color: navy;">=</span> x1<span style="color: teal;">;</span> x1 <span style="color: navy;">=</span> y1<span style="color: teal;">;</span> y1 <span style="color: navy;">=</span> t<span style="color: teal;">;</span> <span style="color: green;">}</span><br />
<span style="color: green;">}</span><br />
<br />
<span style="color: blue;">if</span><span style="color: green;">(</span>x1<span style="color: navy;"><</span>x0<span style="color: green;">)</span><br />
<span style="color: green;">{</span><br />
t <span style="color: navy;">=</span> x1<span style="color: teal;">;</span> x1 <span style="color: navy;">=</span> x0<span style="color: teal;">;</span> x0 <span style="color: navy;">=</span> t<span style="color: teal;">;</span><br />
t <span style="color: navy;">=</span> y1<span style="color: teal;">;</span> y1 <span style="color: navy;">=</span> y0<span style="color: teal;">;</span> y0 <span style="color: navy;">=</span> t<span style="color: teal;">;</span><br />
<span style="color: green;">}</span><br />
<span style="color: red; font-style: italic;">/* ---------------------------------------------------- */</span><br />
<br />
<span style="color: red; font-style: italic;">/* ---------------------------------------------------- */</span><br />
<span style="color: blue;">int</span> twoDY <span style="color: navy;">=</span> 2<span style="color: #000040;">*</span><span style="color: green;">(</span>y1<span style="color: #000040;">-</span>y0<span style="color: green;">)</span>, twoDX <span style="color: navy;">=</span> 2<span style="color: #000040;">*</span><span style="color: green;">(</span>x1<span style="color: #000040;">-</span>x0<span style="color: green;">)</span>, DX <span style="color: navy;">=</span> x1<span style="color: #000040;">-</span>x0<span style="color: teal;">;</span><br />
<span style="color: blue;">int</span> incY <span style="color: navy;">=</span> <span style="color: green;">(</span><span style="color: green;">(</span>twoDY <span style="color: navy;"><</span> 0<span style="color: green;">)</span> <span style="color: teal;">?</span> <span style="color: #000040;">-</span>1 <span style="color: teal;">:</span> 1<span style="color: green;">)</span><span style="color: teal;">;</span><br />
twoDY <span style="color: navy;">=</span> <span style="color: #0000dd;">abs</span><span style="color: green;">(</span>twoDY<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: blue;">int</span> p <span style="color: navy;">=</span> twoDY <span style="color: #000040;">-</span> DX<span style="color: teal;">;</span> <span style="color: blue;">int</span> x <span style="color: navy;">=</span> x0, y <span style="color: navy;">=</span> y0<span style="color: teal;">;</span><br />
<br />
<span style="color: red; font-style: italic;">/* put a pixel at (x, y) */</span><br />
<span style="color: blue;">if</span><span style="color: green;">(</span>inverse<span style="color: green;">)</span><span style="color: green;">{</span><br />
<span style="color: blue;">if</span><span style="color: green;">(</span>sign<span style="color: green;">)</span><br />
setPixel<span style="color: green;">(</span>_CX <span style="color: #000040;">-</span> y, _CY <span style="color: #000040;">+</span> x<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: blue;">else</span><br />
setPixel<span style="color: green;">(</span>_CX <span style="color: #000040;">+</span> y, _CY <span style="color: #000040;">-</span> x<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: green;">}</span> <span style="color: blue;">else</span><br />
setPixel<span style="color: green;">(</span>_CX <span style="color: #000040;">+</span> x, _CY <span style="color: #000040;">-</span> y<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: red; font-style: italic;">/* --------------------- */</span><br />
<br />
<span style="color: blue;">while</span><span style="color: green;">(</span>x <span style="color: navy;"><</span> x1<span style="color: green;">)</span> <span style="color: green;">{</span><br />
<span style="color: #000040;">++</span>x<span style="color: teal;">;</span><br />
<span style="color: blue;">if</span><span style="color: green;">(</span><span style="color: #000040;">!</span><span style="color: green;">(</span>p<span style="color: navy;"><</span>0<span style="color: green;">)</span><span style="color: green;">)</span> <span style="color: green;">{</span><br />
y <span style="color: #000040;">+</span><span style="color: navy;">=</span> incY<span style="color: teal;">;</span><br />
p <span style="color: #000040;">-</span><span style="color: navy;">=</span> twoDX<span style="color: teal;">;</span><br />
<span style="color: green;">}</span><br />
p <span style="color: #000040;">+</span><span style="color: navy;">=</span> twoDY<span style="color: teal;">;</span><br />
<span style="color: red; font-style: italic;">/* put a pixel at (x, y) */</span><br />
<span style="color: blue;">if</span><span style="color: green;">(</span>inverse<span style="color: green;">)</span><span style="color: green;">{</span><br />
<span style="color: blue;">if</span><span style="color: green;">(</span>sign<span style="color: green;">)</span><br />
setPixel<span style="color: green;">(</span>_CX <span style="color: #000040;">-</span> y, _CY <span style="color: #000040;">+</span> x<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: blue;">else</span><br />
setPixel<span style="color: green;">(</span>_CX <span style="color: #000040;">+</span> y, _CY <span style="color: #000040;">-</span> x<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: green;">}</span> <span style="color: blue;">else</span><br />
setPixel<span style="color: green;">(</span>_CX <span style="color: #000040;">+</span> x, _CY <span style="color: #000040;">-</span> y<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: red; font-style: italic;">/* --------------------- */</span><br />
<span style="color: green;">}</span><br />
<span style="color: red; font-style: italic;">/* ---------------------------------------------------- */</span><br />
<span style="color: blue;">if</span><span style="color: green;">(</span>isTRANS<span style="color: green;">)</span><br />
_TRANS <span style="color: navy;">=</span> <span style="color: #0000dd;">1</span><span style="color: teal;">;</span><br />
<span style="color: green;">}</span><br />
<br />
<span style="color: red; font-style: italic;">/*<br /> * helper for 'circle' function<br /> * it uses the symmetry of Circle to draw points in other octants<br /> */</span><br />
<span style="color: blue;">static</span> <span style="color: blue;">inline</span> <span style="color: blue;">void</span> _draw<span style="color: green;">(</span><span style="color: blue;">int</span> xc, <span style="color: blue;">int</span> yc, <span style="color: blue;">int</span> x, <span style="color: blue;">int</span> y<span style="color: green;">)</span> <span style="color: green;">{</span><br />
setPixel<span style="color: green;">(</span>_CX <span style="color: #000040;">+</span> xc<span style="color: #000040;">+</span>x, _CY <span style="color: #000040;">-</span> <span style="color: green;">(</span>yc<span style="color: #000040;">+</span>y<span style="color: green;">)</span> <span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">// Ist Octant</span><br />
setPixel<span style="color: green;">(</span>_CX <span style="color: #000040;">+</span> xc<span style="color: #000040;">+</span>y, _CY <span style="color: #000040;">-</span> <span style="color: green;">(</span>yc<span style="color: #000040;">+</span>x<span style="color: green;">)</span> <span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">// IInd Octant</span><br />
setPixel<span style="color: green;">(</span>_CX <span style="color: #000040;">+</span> xc<span style="color: #000040;">-</span>y, _CY <span style="color: #000040;">-</span> <span style="color: green;">(</span>yc<span style="color: #000040;">+</span>x<span style="color: green;">)</span> <span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">// IIIrd Octant</span><br />
setPixel<span style="color: green;">(</span>_CX <span style="color: #000040;">+</span> xc<span style="color: #000040;">-</span>x, _CY <span style="color: #000040;">-</span> <span style="color: green;">(</span>yc<span style="color: #000040;">+</span>y<span style="color: green;">)</span> <span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">// IVth Octant</span><br />
setPixel<span style="color: green;">(</span>_CX <span style="color: #000040;">+</span> xc<span style="color: #000040;">-</span>x, _CY <span style="color: #000040;">-</span> <span style="color: green;">(</span>yc<span style="color: #000040;">-</span>y<span style="color: green;">)</span> <span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">// Vth Octant</span><br />
setPixel<span style="color: green;">(</span>_CX <span style="color: #000040;">+</span> xc<span style="color: #000040;">-</span>y, _CY <span style="color: #000040;">-</span> <span style="color: green;">(</span>yc<span style="color: #000040;">-</span>x<span style="color: green;">)</span> <span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">// VIth Octant</span><br />
setPixel<span style="color: green;">(</span>_CX <span style="color: #000040;">+</span> xc<span style="color: #000040;">+</span>y, _CY <span style="color: #000040;">-</span> <span style="color: green;">(</span>yc<span style="color: #000040;">-</span>x<span style="color: green;">)</span> <span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">// VIIth Octant</span><br />
setPixel<span style="color: green;">(</span>_CX <span style="color: #000040;">+</span> xc<span style="color: #000040;">+</span>x, _CY <span style="color: #000040;">-</span> <span style="color: green;">(</span>yc<span style="color: #000040;">-</span>y<span style="color: green;">)</span> <span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">// VIIIth Octant</span><br />
<span style="color: green;">}</span><br />
<br />
<br />
<span style="color: red; font-style: italic;">/*<br /> * circle drawing function on the screen<br /> * implements : Midpoint Circle Algorithm<br /> * parameters :<br /> * xc, yc - center of the circle<br /> * radius - radius of the circle<br /> * color - color of line, default value -1 indicates<br /> * we will use last defined color<br /> */</span><br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> circle_r<span style="color: green;">(</span><span style="color: blue;">int</span> xc, <span style="color: blue;">int</span> yc, <span style="color: blue;">const</span> <span style="color: blue;">int</span> radius, <span style="color: blue;">const</span> <span style="color: blue;">int</span> color<span style="color: green;">)</span><br />
<span style="color: green;">{</span><br />
<span style="color: blue;">if</span><span style="color: green;">(</span>color <span style="color: #000040;">!</span><span style="color: navy;">=</span> <span style="color: #000040;">-</span>1<span style="color: green;">)</span><br />
_COLOR <span style="color: navy;">=</span> color<span style="color: teal;">;</span><br />
<br />
<span style="color: blue;">int</span> p <span style="color: navy;">=</span> 1 <span style="color: #000040;">-</span> radius<span style="color: teal;">;</span><br />
<span style="color: blue;">int</span> x <span style="color: navy;">=</span> 0, y <span style="color: navy;">=</span> radius<span style="color: teal;">;</span><br />
<span style="color: blue;">do</span><span style="color: green;">{</span><br />
_draw<span style="color: green;">(</span>xc, yc, x, y<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: #000040;">++</span>x<span style="color: teal;">;</span><br />
<span style="color: blue;">if</span> <span style="color: green;">(</span>p <span style="color: navy;"><</span> 0<span style="color: green;">)</span><br />
p <span style="color: #000040;">+</span><span style="color: navy;">=</span> 1 <span style="color: #000040;">+</span> <span style="color: green;">(</span>x<span style="color: navy;"><<</span>1<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: blue;">else</span><span style="color: green;">{</span><br />
<span style="color: #000040;">--</span>y<span style="color: teal;">;</span><br />
p <span style="color: #000040;">+</span><span style="color: navy;">=</span> 1 <span style="color: #000040;">-</span> <span style="color: green;">(</span><span style="color: green;">(</span>y<span style="color: #000040;">-</span>x<span style="color: green;">)</span> <span style="color: navy;"><<</span> 1<span style="color: green;">)</span> <span style="color: teal;">;</span><br />
<span style="color: green;">}</span><br />
<span style="color: green;">}</span><span style="color: blue;">while</span><span style="color: green;">(</span>y <span style="color: navy;">>=</span> x<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: green;">}</span><br />
<br />
<span style="color: red; font-style: italic;">/*<br /> * helper for 'ellipse' function<br /> * it uses the symmetry of Ellipse to draw points in other quadrants<br /> */</span><br />
<span style="color: blue;">static</span> <span style="color: blue;">inline</span> <span style="color: blue;">void</span> draw_E<span style="color: green;">(</span><span style="color: blue;">int</span> xc, <span style="color: blue;">int</span> yc, <span style="color: blue;">int</span> x, <span style="color: blue;">int</span> y<span style="color: green;">)</span> <br />
<span style="color: green;">{</span><br />
setPixel<span style="color: green;">(</span>_CX <span style="color: #000040;">+</span> xc<span style="color: #000040;">+</span>x, _CY <span style="color: #000040;">-</span> <span style="color: green;">(</span>yc<span style="color: #000040;">+</span>y<span style="color: green;">)</span><span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">// Ist Quadrant</span><br />
setPixel<span style="color: green;">(</span>_CX <span style="color: #000040;">+</span> xc<span style="color: #000040;">-</span>x, _CY <span style="color: #000040;">-</span> <span style="color: green;">(</span>yc<span style="color: #000040;">+</span>y<span style="color: green;">)</span><span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">// IInd Quadrant</span><br />
setPixel<span style="color: green;">(</span>_CX <span style="color: #000040;">+</span> xc<span style="color: #000040;">-</span>x, _CY <span style="color: #000040;">-</span> <span style="color: green;">(</span>yc<span style="color: #000040;">-</span>y<span style="color: green;">)</span><span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">// IIIrd Quadrant</span><br />
setPixel<span style="color: green;">(</span>_CX <span style="color: #000040;">+</span> xc<span style="color: #000040;">+</span>x, _CY <span style="color: #000040;">-</span> <span style="color: green;">(</span>yc<span style="color: #000040;">-</span>y<span style="color: green;">)</span><span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">// IVth Quadrant</span><br />
<span style="color: green;">}</span><br />
<span style="color: red; font-style: italic;">/*<br /> * ellipse drawing function on the screen<br /> * implements : Midpoint Ellipse Algorithm<br /> * parameters :<br /> * xc, yc - center of the ellipse<br /> * rx, ry - axes of the ellipse<br /> * color - color of line, default value -1 indicates<br /> * we will use last defined color<br /> */</span><br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> ellipse_r<span style="color: green;">(</span><span style="color: blue;">int</span> xc, <span style="color: blue;">int</span> yc, <span style="color: blue;">int</span> rx, <span style="color: blue;">int</span> ry, <span style="color: blue;">const</span> <span style="color: blue;">int</span> color<span style="color: green;">)</span> <br />
<span style="color: green;">{</span><br />
<span style="color: blue;">if</span><span style="color: green;">(</span>color <span style="color: #000040;">!</span><span style="color: navy;">=</span> <span style="color: #000040;">-</span>1<span style="color: green;">)</span><br />
_COLOR <span style="color: navy;">=</span> color<span style="color: teal;">;</span><br />
<br />
<span style="color: blue;">long</span> <span style="color: blue;">long</span> <span style="color: blue;">int</span> rx_2 <span style="color: navy;">=</span> rx<span style="color: #000040;">*</span>rx, ry_2 <span style="color: navy;">=</span> ry<span style="color: #000040;">*</span>ry<span style="color: teal;">;</span><br />
<span style="color: blue;">long</span> <span style="color: blue;">long</span> <span style="color: blue;">int</span> p <span style="color: navy;">=</span> ry_2 <span style="color: #000040;">-</span> rx_2<span style="color: #000040;">*</span>ry <span style="color: #000040;">+</span> <span style="color: green;">(</span>ry_2<span style="color: navy;">>></span>2<span style="color: green;">)</span><span style="color: teal;">;</span> <br />
<span style="color: blue;">int</span> x <span style="color: navy;">=</span> 0, y <span style="color: navy;">=</span> ry<span style="color: teal;">;</span><br />
<span style="color: blue;">long</span> <span style="color: blue;">long</span> <span style="color: blue;">int</span> two_ry_2_x <span style="color: navy;">=</span> 0, two_rx_2_y <span style="color: navy;">=</span> <span style="color: green;">(</span>rx_2<span style="color: navy;"><<</span>1<span style="color: green;">)</span><span style="color: #000040;">*</span>y<span style="color: teal;">;</span><br />
draw_E<span style="color: green;">(</span>xc, yc, x, y<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: blue;">while</span><span style="color: green;">(</span>two_rx_2_y <span style="color: navy;">>=</span> two_ry_2_x<span style="color: green;">)</span><span style="color: green;">{</span><br />
<span style="color: #000040;">++</span>x<span style="color: teal;">;</span><br />
two_ry_2_x <span style="color: #000040;">+</span><span style="color: navy;">=</span> <span style="color: green;">(</span>ry_2<span style="color: navy;"><<</span>1<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<br />
p <span style="color: #000040;">+</span><span style="color: navy;">=</span> two_ry_2_x <span style="color: #000040;">+</span> ry_2<span style="color: teal;">;</span><br />
<br />
<span style="color: blue;">if</span><span style="color: green;">(</span>p <span style="color: navy;">>=</span> 0<span style="color: green;">)</span><span style="color: green;">{</span><br />
<span style="color: #000040;">--</span>y<span style="color: teal;">;</span><br />
two_rx_2_y <span style="color: #000040;">-</span><span style="color: navy;">=</span> <span style="color: green;">(</span>rx_2<span style="color: navy;"><<</span>1<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<br />
p <span style="color: #000040;">-</span><span style="color: navy;">=</span> two_rx_2_y <span style="color: teal;">;</span><br />
<span style="color: green;">}</span><br />
draw_E<span style="color: green;">(</span>xc, yc, x, y<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: green;">}</span><br />
<br />
p <span style="color: navy;">=</span> <span style="color: green;">(</span><span style="color: blue;">long</span> <span style="color: blue;">long</span> <span style="color: blue;">int</span><span style="color: green;">)</span><span style="color: green;">(</span>ry_2<span style="color: #000040;">*</span><span style="color: green;">(</span>x<span style="color: #000040;">+</span>1<span style="color: #000040;">/</span>2.0<span style="color: green;">)</span><span style="color: #000040;">*</span><span style="color: green;">(</span>x<span style="color: #000040;">+</span>1<span style="color: #000040;">/</span>2.0<span style="color: green;">)</span> <span style="color: #000040;">+</span> rx_2<span style="color: #000040;">*</span><span style="color: green;">(</span>y<span style="color: #000040;">-</span>1<span style="color: green;">)</span><span style="color: #000040;">*</span><span style="color: green;">(</span>y<span style="color: #000040;">-</span>1<span style="color: green;">)</span> <span style="color: #000040;">-</span> rx_2<span style="color: #000040;">*</span>ry_2<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: blue;">while</span> <span style="color: green;">(</span>y<span style="color: navy;">>=</span>0<span style="color: green;">)</span> <span style="color: green;">{</span><br />
p <span style="color: #000040;">+</span><span style="color: navy;">=</span> rx_2<span style="color: teal;">;</span><br />
<span style="color: #000040;">--</span>y<span style="color: teal;">;</span><br />
two_rx_2_y <span style="color: #000040;">-</span><span style="color: navy;">=</span> <span style="color: green;">(</span>rx_2<span style="color: navy;"><<</span>1<span style="color: green;">)</span><span style="color: teal;">;</span><br />
p <span style="color: #000040;">-</span><span style="color: navy;">=</span> two_rx_2_y<span style="color: teal;">;</span><br />
<br />
<span style="color: blue;">if</span><span style="color: green;">(</span>p <span style="color: navy;"><=</span> 0<span style="color: green;">)</span> <span style="color: green;">{</span><br />
<span style="color: #000040;">++</span>x<span style="color: teal;">;</span><br />
two_ry_2_x <span style="color: #000040;">+</span><span style="color: navy;">=</span> <span style="color: green;">(</span>ry_2<span style="color: navy;"><<</span>1<span style="color: green;">)</span><span style="color: teal;">;</span><br />
p <span style="color: #000040;">+</span><span style="color: navy;">=</span> two_ry_2_x<span style="color: teal;">;</span><br />
<span style="color: green;">}</span><br />
draw_E<span style="color: green;">(</span>xc, yc, x, y<span style="color: green;">)</span><span style="color: teal;">;</span><br />
<span style="color: green;">}</span><br />
<span style="color: green;">}</span><br />
<br />
</div>
<br />
<br />
<div style="background-color: yellow; color: blue; font-family: 'Courier New',Courier,monospace;">
<span style="font-size: large;"><b>FILE : wheel.cpp</b></span> <br />
</div>
<div class="cpp" style="font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"><span style="color: #ff0000; font-style: italic;">/*<br />
* wheel.cpp<br />
*<br />
* Copyright 2009 Rooparam Choudhary <rooparambhakar@gmail.com><br />
*<br />
* This program is free software; you can redistribute it and/or modify<br />
* it under the terms of the GNU General Public License as published by<br />
* the Free Software Foundation; either version 2 of the License, or<br />
* (at your option) any later version.<br />
*<br />
* This program is distributed in the hope that it will be useful,<br />
* but WITHOUT ANY WARRANTY; without even the implied warranty of<br />
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br />
* GNU General Public License for more details.<br />
*<br />
* You should have received a copy of the GNU General Public License<br />
* along with this program; if not, write to the Free Software<br />
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,<br />
* MA 02110-1301, USA.<br />
*/</span><br />
<span style="color: #339900;">#include <iostream></span><br />
<span style="color: #339900;">#include <stdio.h></span><br />
<span style="color: #339900;">#include <math.h></span><br />
<span style="color: #339900;">#include "rrc.cpp"</span><br />
<br />
<span style="color: #339900;">#define PI 3.14159f</span><br />
<span style="color: #339900;">#define ee 0.85f // collision constant</span><br />
<span style="color: #339900;">#define CLOCK 0.2f // tick increment</span><br />
<span style="color: #666666;">// #define _PEL_DO</span><br />
<br />
<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> draw_wheel<span style="color: #008000;">(</span><span style="color: #0000ff;">int</span> xc, <span style="color: #0000ff;">int</span> yc, <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">int</span> radius, <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">float</span> theta<span style="color: #008000;">)</span><br />
<span style="color: #008000;">{</span><br />
<span style="color: #0000ff;">int</span> temp <span style="color: #000080;">=</span> _TRANS<span style="color: #008080;">;</span><br />
_TRANS <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span><br />
SetToIdentity<span style="color: #008000;">(</span>_M<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
Rotate<span style="color: #008000;">(</span>_M, theta<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #666666;">// Translate(_M, xc, yc);</span><br />
_M<span style="color: #008000;">[</span>0<span style="color: #008000;">]</span><span style="color: #008000;">[</span>2<span style="color: #008000;">]</span> <span style="color: #000080;">=</span> xc<span style="color: #008080;">;</span> _M<span style="color: #008000;">[</span>1<span style="color: #008000;">]</span><span style="color: #008000;">[</span>2<span style="color: #008000;">]</span> <span style="color: #000080;">=</span> yc<span style="color: #008080;">;</span><br />
<br />
<span style="color: #0000ff;">int</span> x0, y0, x1, y1<span style="color: #008080;">;</span> <br />
<span style="color: #0000ff;">float</span> rim <span style="color: #000080;">=</span> 4.0f<span style="color: #000040;">/</span><span style="color:#800080;">5.0f</span><span style="color: #008080;">;</span> <br />
<br />
<span style="color: #666666;">// first spike of wheel</span><br />
x0 <span style="color: #000080;">=</span> <span style="color: #0000ff;">int</span><span style="color: #008000;">(</span><span style="color: #000040;">-</span>radius<span style="color: #000040;">*</span>rim<span style="color: #008000;">)</span><span style="color: #008080;">;</span> y0 <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span><br />
x1 <span style="color: #000080;">=</span> <span style="color: #0000ff;">int</span><span style="color: #008000;">(</span>radius<span style="color: #000040;">*</span>rim<span style="color: #008000;">)</span><span style="color: #008080;">;</span> y1 <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>x0, y0, x1, y1, RED<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
_M<span style="color: #008000;">[</span>1<span style="color: #008000;">]</span><span style="color: #008000;">[</span>2<span style="color: #008000;">]</span> <span style="color: #000040;">-</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>x0<span style="color: #000040;">+</span>1, y0, x1<span style="color: #000040;">-</span>1, y1, RED<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
_M<span style="color: #008000;">[</span>1<span style="color: #008000;">]</span><span style="color: #008000;">[</span>2<span style="color: #008000;">]</span> <span style="color: #000040;">+</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">2</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>x0<span style="color: #000040;">+</span>1, y0, x1<span style="color: #000040;">-</span>1, y1, RED<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
_M<span style="color: #008000;">[</span>1<span style="color: #008000;">]</span><span style="color: #008000;">[</span>2<span style="color: #008000;">]</span> <span style="color: #000040;">-</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #666666;">// second spike of wheel</span><br />
x0 <span style="color: #000080;">=</span> <span style="color: #0000ff;">int</span><span style="color: #008000;">(</span><span style="color: #000040;">-</span>0.5f<span style="color: #000040;">*</span>radius<span style="color: #000040;">*</span>rim<span style="color: #008000;">)</span><span style="color: #008080;">;</span> y0 <span style="color: #000080;">=</span> <span style="color: #0000ff;">int</span><span style="color: #008000;">(</span><span style="color: #000040;">-</span>0.866f<span style="color: #000040;">*</span>radius<span style="color: #000040;">*</span>rim<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
x1 <span style="color: #000080;">=</span> <span style="color: #0000ff;">int</span><span style="color: #008000;">(</span>0.5f<span style="color: #000040;">*</span>radius<span style="color: #000040;">*</span>rim<span style="color: #008000;">)</span><span style="color: #008080;">;</span> y1 <span style="color: #000080;">=</span> <span style="color: #0000ff;">int</span><span style="color: #008000;">(</span>0.866f<span style="color: #000040;">*</span>radius<span style="color: #000040;">*</span>rim<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>x0, y0, x1, y1, GREEN<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
_M<span style="color: #008000;">[</span>0<span style="color: #008000;">]</span><span style="color: #008000;">[</span>2<span style="color: #008000;">]</span> <span style="color: #000040;">+</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>x0, y0, x1<span style="color: #000040;">-</span>1, y1<span style="color: #000040;">-</span>1, GREEN<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
_M<span style="color: #008000;">[</span>0<span style="color: #008000;">]</span><span style="color: #008000;">[</span>2<span style="color: #008000;">]</span> <span style="color: #000040;">-</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">2</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>x0<span style="color: #000040;">-</span>1, y0<span style="color: #000040;">-</span>1, x1, y1, GREEN<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
_M<span style="color: #008000;">[</span>0<span style="color: #008000;">]</span><span style="color: #008000;">[</span>2<span style="color: #008000;">]</span> <span style="color: #000040;">+</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #666666;">// third spike of wheel</span><br />
x0 <span style="color: #000080;">=</span> <span style="color: #0000ff;">int</span><span style="color: #008000;">(</span><span style="color: #000040;">-</span>0.5f<span style="color: #000040;">*</span>radius<span style="color: #000040;">*</span>rim<span style="color: #008000;">)</span><span style="color: #008080;">;</span> y0 <span style="color: #000080;">=</span> <span style="color: #0000ff;">int</span><span style="color: #008000;">(</span>0.866f<span style="color: #000040;">*</span>radius<span style="color: #000040;">*</span>rim<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
x1 <span style="color: #000080;">=</span> <span style="color: #0000ff;">int</span><span style="color: #008000;">(</span>0.5f<span style="color: #000040;">*</span>radius<span style="color: #000040;">*</span>rim<span style="color: #008000;">)</span><span style="color: #008080;">;</span> y1 <span style="color: #000080;">=</span> <span style="color: #0000ff;">int</span><span style="color: #008000;">(</span><span style="color: #000040;">-</span>0.866f<span style="color: #000040;">*</span>radius<span style="color: #000040;">*</span>rim<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>x0, y0, x1, y1, BLUE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
_M<span style="color: #008000;">[</span>0<span style="color: #008000;">]</span><span style="color: #008000;">[</span>2<span style="color: #008000;">]</span> <span style="color: #000040;">+</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>x0, y0, x1<span style="color: #000040;">-</span>1, y1<span style="color: #000040;">+</span>1, BLUE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
_M<span style="color: #008000;">[</span>0<span style="color: #008000;">]</span><span style="color: #008000;">[</span>2<span style="color: #008000;">]</span> <span style="color: #000040;">-</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">2</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>x0<span style="color: #000040;">+</span>1, y0<span style="color: #000040;">-</span>1, x1, y1, BLUE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
_M<span style="color: #008000;">[</span>0<span style="color: #008000;">]</span><span style="color: #008000;">[</span>2<span style="color: #008000;">]</span> <span style="color: #000040;">+</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #666666;">// drawing tyre</span><br />
_TRANS <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span><br />
circle_r<span style="color: #008000;">(</span>xc, yc, <span style="color: #0000ff;">int</span><span style="color: #008000;">(</span>radius<span style="color: #000040;">*</span>rim<span style="color: #008000;">)</span>, BLACK<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
circle_r<span style="color: #008000;">(</span>xc, yc, <span style="color: #0000ff;">int</span><span style="color: #008000;">(</span>radius<span style="color: #000040;">*</span>rim<span style="color: #000040;">-</span>1<span style="color: #008000;">)</span>, BLACK<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">int</span> my_r <span style="color: #000080;">=</span> <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span><span style="color: #008000;">(</span>radius<span style="color: #000040;">*</span>rim<span style="color: #000040;">+</span>4.0f<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">do</span><span style="color: #008000;">{</span><br />
circle_r<span style="color: #008000;">(</span>xc, yc, my_r, BLACK<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
my_r <span style="color: #000040;">+</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">4</span><span style="color: #008080;">;</span><br />
<span style="color: #008000;">}</span> <span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>my_r <span style="color: #000080;"><</span> <span style="color: #008000;">(</span>radius<span style="color: #000040;">-</span>5<span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
circle_r<span style="color: #008000;">(</span>xc, yc, radius, BLACK<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
circle_r<span style="color: #008000;">(</span>xc, yc, radius<span style="color: #000040;">-</span>1, BLACK<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
circle_r<span style="color: #008000;">(</span>xc, yc, radius<span style="color: #000040;">-</span>2, BLACK<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
_TRANS <span style="color: #000080;">=</span> temp<span style="color: #008080;">;</span><br />
<span style="color: #008000;">}</span><br />
<br />
<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> simulate<span style="color: #008000;">(</span><span style="color: #0000ff;">float</span> angle, <span style="color: #0000ff;">float</span> radius, <span style="color: #0000ff;">float</span> g<span style="color: #008000;">)</span><br />
<span style="color: #008000;">{</span><br />
<span style="color: #0000ff;">char</span> <span style="color: #000040;">*</span>author <span style="color: #000080;">=</span> <span style="color: #FF0000;">"Coder:- Rooparam Choudhary"</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #0000ff;">float</span> ix, iy<span style="color: #008080;">;</span> <span style="color: #666666;">// (ix, iy) : upper end of wedge</span><br />
<br />
setbkcolor<span style="color: #008000;">(</span>WHITE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #0000ff;">if</span><span style="color: #008000;">(</span><span style="color: #0000dd;">tan</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span> <span style="color: #000080;"><=</span> <span style="color: #008000;">(</span><span style="color: #0000ff;">float</span><span style="color: #008000;">)</span>_CY<span style="color: #000040;">/</span><span style="color: #008000;">(</span>_WIDTH <span style="color: #000040;">-</span> _CX<span style="color: #008000;">)</span> <span style="color: #008000;">)</span> <span style="color: #008000;">{</span><br />
ix <span style="color: #000080;">=</span> <span style="color: #008000;">(</span><span style="color: #0000ff;">float</span><span style="color: #008000;">)</span><span style="color: #008000;">(</span>_WIDTH <span style="color: #000040;">-</span> _CX<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
iy <span style="color: #000080;">=</span> ix <span style="color: #000040;">*</span> <span style="color: #0000dd;">tan</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #008000;">}</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">{</span><br />
iy <span style="color: #000080;">=</span> <span style="color: #008000;">(</span><span style="color: #0000ff;">float</span><span style="color: #008000;">)</span>_CY<span style="color: #008080;">;</span><br />
ix <span style="color: #000080;">=</span> iy <span style="color: #000040;">/</span> <span style="color: #0000dd;">tan</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #008000;">}</span><br />
<br />
<span style="color: #666666;">// (x, y) : wheel center</span><br />
<span style="color: #0000ff;">float</span> x <span style="color: #000080;">=</span> ix <span style="color: #000040;">-</span> radius<span style="color: #000040;">*</span><span style="color: #008000;">(</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span> <span style="color: #000040;">+</span> <span style="color: #0000dd;">sin</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">float</span> y <span style="color: #000080;">=</span> iy <span style="color: #000040;">+</span> radius<span style="color: #000040;">*</span><span style="color: #008000;">(</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span> <span style="color: #000040;">-</span> <span style="color: #0000dd;">sin</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #0000ff;">float</span> C1 <span style="color: #000080;">=</span> g<span style="color: #000040;">*</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #000040;">/</span><span style="color:#800080;">4.0f</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">float</span> C2 <span style="color: #000080;">=</span> C1<span style="color: #000040;">/</span>radius<span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">float</span> tick<span style="color: #008080;">;</span> <span style="color: #666666;">// discrete time, increment on every iteration of while loop</span><br />
<span style="color: #0000ff;">float</span> twoT<span style="color: #008080;">;</span><br />
<br />
<span style="color: #0000ff;">float</span> h, h1, t, t1, energy, speed, MAX<span style="color: #008080;">;</span><br />
h <span style="color: #000080;">=</span> y<span style="color: #000040;">-</span>radius<span style="color: #000040;">/</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
energy <span style="color: #000080;">=</span> g<span style="color: #000040;">*</span>h<span style="color: #008080;">;</span><br />
MAX <span style="color: #000080;">=</span> energy<span style="color: #008080;">;</span><br />
<br />
<span style="color: #0000ff;">float</span> theta <span style="color: #000080;">=</span> <span style="color:#800080;">0.0f</span><span style="color: #008080;">;</span> <span style="color: #666666;">// rotation angle of wheel (in radians)</span><br />
<span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>energy <span style="color: #000080;">></span> <span style="color:#800080;">0.01f</span><span style="color: #000040;">*</span>MAX<span style="color: #008000;">)</span><br />
<span style="color: #008000;">{</span><br />
<span style="color: #666666;">// rotating down the slope from upper right.</span><br />
t <span style="color: #000080;">=</span> 2.0f<span style="color: #000040;">/</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #000040;">*</span>sqrtf<span style="color: #008000;">(</span>h<span style="color: #000040;">/</span>g<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
tick <span style="color: #000080;">=</span> <span style="color:#800080;">0.0f</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">do</span><br />
<span style="color: #008000;">{</span><br />
cleardevice<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setcolor<span style="color: #008000;">(</span>WHITE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setbkcolor<span style="color: #008000;">(</span>GREEN<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
outtextxy<span style="color: #008000;">(</span>getmaxx<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>4 <span style="color: #000040;">-</span>textwidth<span style="color: #008000;">(</span>author<span style="color: #008000;">)</span>, getmaxy<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>20, author<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setbkcolor<span style="color: #008000;">(</span>WHITE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #666666;">// draw wedge</span><br />
line_r<span style="color: #008000;">(</span>0, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>ix, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #ff0000; font-style: italic;">/*<br />
line_r(1, 0, (int)ix+1, (int)iy, MAGENTA);<br />
line_r(2, 0, (int)ix+2, (int)iy, MAGENTA);<br />
line_r(3, 0, (int)ix+3, (int)iy, MAGENTA);<br />
line_r(4, 0, (int)ix+4, (int)iy, MAGENTA);<br />
*/</span><br />
line_r<span style="color: #008000;">(</span>5, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>ix<span style="color: #000040;">+</span>5, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>0, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>ix, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #ff0000; font-style: italic;">/*<br />
line_r(-1, 0, (int)-ix-1, (int)iy, MAGENTA);<br />
line_r(-2, 0, (int)-ix-2, (int)iy, MAGENTA);<br />
line_r(-3, 0, (int)-ix-3, (int)iy, MAGENTA);<br />
line_r(-4, 0, (int)-ix-4, (int)iy, MAGENTA);<br />
*/</span><br />
line_r<span style="color: #008000;">(</span><span style="color: #000040;">-</span>5, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>ix<span style="color: #000040;">-</span>5, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
draw_wheel<span style="color: #008000;">(</span><span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>x, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>y, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>radius, theta<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
swapbuffers<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #339900;">#ifdef _PEL_DO</span><br />
cleardevice<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setcolor<span style="color: #008000;">(</span>WHITE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setbkcolor<span style="color: #008000;">(</span>GREEN<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
outtextxy<span style="color: #008000;">(</span>getmaxx<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>4 <span style="color: #000040;">-</span>textwidth<span style="color: #008000;">(</span>author<span style="color: #008000;">)</span>, getmaxy<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>20, author<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setbkcolor<span style="color: #008000;">(</span>WHITE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #666666;">// draw wedge</span><br />
line_r<span style="color: #008000;">(</span>0, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>ix, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #ff0000; font-style: italic;">/*<br />
line_r(1, 0, (int)ix+1, (int)iy, MAGENTA);<br />
line_r(2, 0, (int)ix+2, (int)iy, MAGENTA);<br />
line_r(3, 0, (int)ix+3, (int)iy, MAGENTA);<br />
line_r(4, 0, (int)ix+4, (int)iy, MAGENTA);<br />
*/</span><br />
line_r<span style="color: #008000;">(</span>5, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>ix<span style="color: #000040;">+</span>5, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>0, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>ix, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #ff0000; font-style: italic;">/*<br />
line_r(-1, 0, (int)-ix-1, (int)iy, MAGENTA);<br />
line_r(-2, 0, (int)-ix-2, (int)iy, MAGENTA);<br />
line_r(-3, 0, (int)-ix-3, (int)iy, MAGENTA);<br />
line_r(-4, 0, (int)-ix-4, (int)iy, MAGENTA);<br />
*/</span><br />
line_r<span style="color: #008000;">(</span><span style="color: #000040;">-</span>5, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>ix<span style="color: #000040;">-</span>5, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
draw_wheel<span style="color: #008000;">(</span><span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>x, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>y, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>radius, theta<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
swapbuffers<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #339900;">#endif </span><br />
twoT <span style="color: #000080;">=</span> <span style="color: #008000;">(</span>CLOCK <span style="color: #000040;">+</span> 2<span style="color: #000040;">*</span>tick<span style="color: #008000;">)</span><span style="color: #000040;">*</span>CLOCK<span style="color: #008080;">;</span><br />
theta <span style="color: #000040;">+</span><span style="color: #000080;">=</span> C2<span style="color: #000040;">*</span>twoT<span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>theta <span style="color: #000080;">>=</span> 2.0f<span style="color: #000040;">*</span>PI<span style="color: #008000;">)</span> <span style="color: #008000;">{</span> theta <span style="color: #000040;">-</span><span style="color: #000080;">=</span> 2.0f<span style="color: #000040;">*</span>PI<span style="color: #008080;">;</span> <span style="color: #008000;">}</span><br />
x <span style="color: #000040;">-</span><span style="color: #000080;">=</span> C1<span style="color: #000040;">*</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #000040;">*</span>twoT<span style="color: #008080;">;</span><br />
y <span style="color: #000040;">-</span><span style="color: #000080;">=</span> C1<span style="color: #000040;">*</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #000040;">*</span>twoT<span style="color: #008080;">;</span><br />
tick <span style="color: #000040;">+</span><span style="color: #000080;">=</span> CLOCK<span style="color: #008080;">;</span><br />
<span style="color: #008000;">}</span> <span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>tick <span style="color: #000080;"><=</span> t<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #666666;">// climbing up the slope from center towards upper left.</span><br />
h1 <span style="color: #000080;">=</span> ee<span style="color: #000040;">*</span>ee<span style="color: #000040;">*</span>h<span style="color: #008080;">;</span><br />
t1 <span style="color: #000080;">=</span> 2.0f<span style="color: #000040;">/</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #000040;">*</span>sqrtf<span style="color: #008000;">(</span>h1<span style="color: #000040;">/</span>g<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
tick <span style="color: #000080;">=</span> <span style="color:#800080;">0.0f</span><span style="color: #008080;">;</span><br />
x <span style="color: #000080;">=</span> <span style="color:#800080;">0.0f</span><span style="color: #008080;">;</span> y <span style="color: #000080;">=</span> radius<span style="color: #000040;">/</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
speed <span style="color: #000080;">=</span> sqrtf<span style="color: #008000;">(</span>g<span style="color: #000040;">*</span>h1<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">do</span><br />
<span style="color: #008000;">{</span><br />
cleardevice<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setcolor<span style="color: #008000;">(</span>WHITE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setbkcolor<span style="color: #008000;">(</span>GREEN<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
outtextxy<span style="color: #008000;">(</span>getmaxx<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>4 <span style="color: #000040;">-</span>textwidth<span style="color: #008000;">(</span>author<span style="color: #008000;">)</span>, getmaxy<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>20, author<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setbkcolor<span style="color: #008000;">(</span>WHITE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #666666;">// draw wedge</span><br />
line_r<span style="color: #008000;">(</span>0, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>ix, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #ff0000; font-style: italic;">/*<br />
line_r(1, 0, (int)ix+1, (int)iy, MAGENTA);<br />
line_r(2, 0, (int)ix+2, (int)iy, MAGENTA);<br />
line_r(3, 0, (int)ix+3, (int)iy, MAGENTA);<br />
line_r(4, 0, (int)ix+4, (int)iy, MAGENTA);<br />
*/</span><br />
line_r<span style="color: #008000;">(</span>5, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>ix<span style="color: #000040;">+</span>5, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>0, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>ix, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #ff0000; font-style: italic;">/*<br />
line_r(-1, 0, (int)-ix-1, (int)iy, MAGENTA);<br />
line_r(-2, 0, (int)-ix-2, (int)iy, MAGENTA);<br />
line_r(-3, 0, (int)-ix-3, (int)iy, MAGENTA);<br />
line_r(-4, 0, (int)-ix-4, (int)iy, MAGENTA);<br />
*/</span><br />
line_r<span style="color: #008000;">(</span><span style="color: #000040;">-</span>5, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>ix<span style="color: #000040;">-</span>5, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
draw_wheel<span style="color: #008000;">(</span><span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>x, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>y, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>radius, theta<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
swapbuffers<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #339900;">#ifdef _PEL_DO </span><br />
cleardevice<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setcolor<span style="color: #008000;">(</span>WHITE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setbkcolor<span style="color: #008000;">(</span>GREEN<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
outtextxy<span style="color: #008000;">(</span>getmaxx<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>4 <span style="color: #000040;">-</span>textwidth<span style="color: #008000;">(</span>author<span style="color: #008000;">)</span>, getmaxy<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>20, author<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setbkcolor<span style="color: #008000;">(</span>WHITE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #666666;">// draw wedge</span><br />
line_r<span style="color: #008000;">(</span>0, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>ix, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #ff0000; font-style: italic;">/*<br />
line_r(1, 0, (int)ix+1, (int)iy, MAGENTA);<br />
line_r(2, 0, (int)ix+2, (int)iy, MAGENTA);<br />
line_r(3, 0, (int)ix+3, (int)iy, MAGENTA);<br />
line_r(4, 0, (int)ix+4, (int)iy, MAGENTA);<br />
*/</span><br />
line_r<span style="color: #008000;">(</span>5, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>ix<span style="color: #000040;">+</span>5, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>0, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>ix, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #ff0000; font-style: italic;">/*<br />
line_r(-1, 0, (int)-ix-1, (int)iy, MAGENTA);<br />
line_r(-2, 0, (int)-ix-2, (int)iy, MAGENTA);<br />
line_r(-3, 0, (int)-ix-3, (int)iy, MAGENTA);<br />
line_r(-4, 0, (int)-ix-4, (int)iy, MAGENTA);<br />
*/</span><br />
line_r<span style="color: #008000;">(</span><span style="color: #000040;">-</span>5, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>ix<span style="color: #000040;">-</span>5, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
draw_wheel<span style="color: #008000;">(</span><span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>x, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>y, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>radius, theta<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
swapbuffers<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #339900;">#endif </span><br />
twoT <span style="color: #000080;">=</span> <span style="color: #008000;">(</span>CLOCK<span style="color: #000040;">+</span>2<span style="color: #000040;">*</span>tick<span style="color: #008000;">)</span><span style="color: #000040;">*</span>CLOCK<span style="color: #008080;">;</span><br />
theta <span style="color: #000040;">+</span><span style="color: #000080;">=</span> speed<span style="color: #000040;">/</span>radius<span style="color: #000040;">*</span>CLOCK <span style="color: #000040;">-</span> C2<span style="color: #000040;">*</span>twoT<span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>theta <span style="color: #000080;">>=</span> 2.0f<span style="color: #000040;">*</span>PI<span style="color: #008000;">)</span> <span style="color: #008000;">{</span> theta <span style="color: #000040;">-</span><span style="color: #000080;">=</span> 2.0f<span style="color: #000040;">*</span>PI<span style="color: #008080;">;</span> <span style="color: #008000;">}</span><br />
x <span style="color: #000040;">-</span><span style="color: #000080;">=</span> <span style="color: #008000;">(</span>speed<span style="color: #000040;">*</span>CLOCK <span style="color: #000040;">-</span> C1<span style="color: #000040;">*</span>twoT<span style="color: #008000;">)</span><span style="color: #000040;">*</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
y <span style="color: #000040;">+</span><span style="color: #000080;">=</span> <span style="color: #008000;">(</span>speed<span style="color: #000040;">*</span>CLOCK <span style="color: #000040;">-</span> C1<span style="color: #000040;">*</span>twoT<span style="color: #008000;">)</span><span style="color: #000040;">*</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
tick <span style="color: #000040;">+</span><span style="color: #000080;">=</span> CLOCK<span style="color: #008080;">;</span><br />
<span style="color: #008000;">}</span> <span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>tick <span style="color: #000080;"><=</span> t1<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #666666;">// rotating down the slope from upper left</span><br />
tick <span style="color: #000080;">=</span> <span style="color:#800080;">0.0f</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">float</span> br, kr<span style="color: #008080;">;</span><br />
kr <span style="color: #000080;">=</span> h1<span style="color: #000040;">+</span>radius<span style="color: #000040;">/</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span> <span style="color: #000040;">-</span> radius<span style="color: #000040;">*</span><span style="color: #008000;">(</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span> <span style="color: #000040;">-</span> <span style="color: #0000dd;">sin</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
br <span style="color: #000080;">=</span> kr<span style="color: #000040;">/</span><span style="color: #0000dd;">tan</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
x <span style="color: #000080;">=</span> <span style="color: #000040;">-</span>br <span style="color: #000040;">+</span> radius<span style="color: #000040;">*</span><span style="color: #008000;">(</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span> <span style="color: #000040;">+</span> <span style="color: #0000dd;">sin</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span> y <span style="color: #000080;">=</span> h1<span style="color: #000040;">+</span>radius<span style="color: #000040;">/</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
speed <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">do</span><br />
<span style="color: #008000;">{</span><br />
cleardevice<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setcolor<span style="color: #008000;">(</span>WHITE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setbkcolor<span style="color: #008000;">(</span>GREEN<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
outtextxy<span style="color: #008000;">(</span>getmaxx<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>4 <span style="color: #000040;">-</span>textwidth<span style="color: #008000;">(</span>author<span style="color: #008000;">)</span>, getmaxy<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>20, author<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setbkcolor<span style="color: #008000;">(</span>WHITE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #666666;">// draw wedge</span><br />
line_r<span style="color: #008000;">(</span>0, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>ix, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #ff0000; font-style: italic;">/*<br />
line_r(1, 0, (int)ix+1, (int)iy, MAGENTA);<br />
line_r(2, 0, (int)ix+2, (int)iy, MAGENTA);<br />
line_r(3, 0, (int)ix+3, (int)iy, MAGENTA);<br />
line_r(4, 0, (int)ix+4, (int)iy, MAGENTA);<br />
*/</span><br />
line_r<span style="color: #008000;">(</span>5, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>ix<span style="color: #000040;">+</span>5, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>0, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>ix, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #ff0000; font-style: italic;">/*<br />
line_r(-1, 0, (int)-ix-1, (int)iy, MAGENTA);<br />
line_r(-2, 0, (int)-ix-2, (int)iy, MAGENTA);<br />
line_r(-3, 0, (int)-ix-3, (int)iy, MAGENTA);<br />
line_r(-4, 0, (int)-ix-4, (int)iy, MAGENTA);<br />
*/</span><br />
line_r<span style="color: #008000;">(</span><span style="color: #000040;">-</span>5, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>ix<span style="color: #000040;">-</span>5, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
draw_wheel<span style="color: #008000;">(</span><span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>x, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>y, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>radius, theta<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
swapbuffers<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #339900;">#ifdef _PEL_DO </span><br />
cleardevice<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setcolor<span style="color: #008000;">(</span>WHITE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setbkcolor<span style="color: #008000;">(</span>GREEN<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
outtextxy<span style="color: #008000;">(</span>getmaxx<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>4 <span style="color: #000040;">-</span>textwidth<span style="color: #008000;">(</span>author<span style="color: #008000;">)</span>, getmaxy<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>20, author<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setbkcolor<span style="color: #008000;">(</span>WHITE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #666666;">// draw wedge</span><br />
line_r<span style="color: #008000;">(</span>0, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>ix, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #ff0000; font-style: italic;">/*<br />
line_r(1, 0, (int)ix+1, (int)iy, MAGENTA);<br />
line_r(2, 0, (int)ix+2, (int)iy, MAGENTA);<br />
line_r(3, 0, (int)ix+3, (int)iy, MAGENTA);<br />
line_r(4, 0, (int)ix+4, (int)iy, MAGENTA);<br />
*/</span><br />
line_r<span style="color: #008000;">(</span>5, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>ix<span style="color: #000040;">+</span>5, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>0, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>ix, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #ff0000; font-style: italic;">/*<br />
line_r(-1, 0, (int)-ix-1, (int)iy, MAGENTA);<br />
line_r(-2, 0, (int)-ix-2, (int)iy, MAGENTA);<br />
line_r(-3, 0, (int)-ix-3, (int)iy, MAGENTA);<br />
line_r(-4, 0, (int)-ix-4, (int)iy, MAGENTA);<br />
*/</span><br />
line_r<span style="color: #008000;">(</span><span style="color: #000040;">-</span>5, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>ix<span style="color: #000040;">-</span>5, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
draw_wheel<span style="color: #008000;">(</span><span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>x, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>y, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>radius, theta<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
swapbuffers<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #339900;">#endif </span><br />
twoT <span style="color: #000080;">=</span> <span style="color: #008000;">(</span>CLOCK<span style="color: #000040;">+</span>2<span style="color: #000040;">*</span>tick<span style="color: #008000;">)</span><span style="color: #000040;">*</span>CLOCK<span style="color: #008080;">;</span><br />
theta <span style="color: #000040;">-</span><span style="color: #000080;">=</span> C2<span style="color: #000040;">*</span>twoT<span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>theta <span style="color: #000080;"><=</span> <span style="color: #000040;">-</span>2.0f<span style="color: #000040;">*</span>PI<span style="color: #008000;">)</span> <span style="color: #008000;">{</span> theta <span style="color: #000040;">+</span><span style="color: #000080;">=</span> 2.0f<span style="color: #000040;">*</span>PI<span style="color: #008080;">;</span> <span style="color: #008000;">}</span><br />
x <span style="color: #000040;">+</span><span style="color: #000080;">=</span> C1<span style="color: #000040;">*</span>twoT<span style="color: #000040;">*</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
y <span style="color: #000040;">-</span><span style="color: #000080;">=</span> C1<span style="color: #000040;">*</span>twoT<span style="color: #000040;">*</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
tick <span style="color: #000040;">+</span><span style="color: #000080;">=</span> CLOCK<span style="color: #008080;">;</span><br />
<span style="color: #008000;">}</span> <span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>tick <span style="color: #000080;"><=</span> t1<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #666666;">// climbing up the slope towards upper right</span><br />
h <span style="color: #000080;">=</span> ee<span style="color: #000040;">*</span>ee<span style="color: #000040;">*</span>h1<span style="color: #008080;">;</span><br />
t <span style="color: #000080;">=</span> 2.0f<span style="color: #000040;">/</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #000040;">*</span>sqrtf<span style="color: #008000;">(</span>h<span style="color: #000040;">/</span>g<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
tick <span style="color: #000080;">=</span> <span style="color:#800080;">0.0f</span><span style="color: #008080;">;</span><br />
x <span style="color: #000080;">=</span> <span style="color:#800080;">0.0f</span><span style="color: #008080;">;</span> y <span style="color: #000080;">=</span> radius<span style="color: #000040;">/</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
speed <span style="color: #000080;">=</span> sqrtf<span style="color: #008000;">(</span>g<span style="color: #000040;">*</span>h<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">do</span><br />
<span style="color: #008000;">{</span><br />
cleardevice<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setcolor<span style="color: #008000;">(</span>WHITE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setbkcolor<span style="color: #008000;">(</span>GREEN<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
outtextxy<span style="color: #008000;">(</span>getmaxx<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>4 <span style="color: #000040;">-</span>textwidth<span style="color: #008000;">(</span>author<span style="color: #008000;">)</span>, getmaxy<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>20, author<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setbkcolor<span style="color: #008000;">(</span>WHITE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #666666;">// draw wedge</span><br />
line_r<span style="color: #008000;">(</span>0, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>ix, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #ff0000; font-style: italic;">/*<br />
line_r(1, 0, (int)ix+1, (int)iy, MAGENTA);<br />
line_r(2, 0, (int)ix+2, (int)iy, MAGENTA);<br />
line_r(3, 0, (int)ix+3, (int)iy, MAGENTA);<br />
line_r(4, 0, (int)ix+4, (int)iy, MAGENTA);<br />
*/</span><br />
line_r<span style="color: #008000;">(</span>5, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>ix<span style="color: #000040;">+</span>5, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>0, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>ix, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #ff0000; font-style: italic;">/*<br />
line_r(-1, 0, (int)-ix-1, (int)iy, MAGENTA);<br />
line_r(-2, 0, (int)-ix-2, (int)iy, MAGENTA);<br />
line_r(-3, 0, (int)-ix-3, (int)iy, MAGENTA);<br />
line_r(-4, 0, (int)-ix-4, (int)iy, MAGENTA);<br />
*/</span><br />
line_r<span style="color: #008000;">(</span><span style="color: #000040;">-</span>5, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>ix<span style="color: #000040;">-</span>5, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
draw_wheel<span style="color: #008000;">(</span><span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>x, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>y, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>radius, theta<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
swapbuffers<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #339900;">#ifdef _PEL_DO </span><br />
cleardevice<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setcolor<span style="color: #008000;">(</span>WHITE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setbkcolor<span style="color: #008000;">(</span>GREEN<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
outtextxy<span style="color: #008000;">(</span>getmaxx<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>4 <span style="color: #000040;">-</span>textwidth<span style="color: #008000;">(</span>author<span style="color: #008000;">)</span>, getmaxy<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>20, author<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setbkcolor<span style="color: #008000;">(</span>WHITE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #666666;">// draw wedge</span><br />
line_r<span style="color: #008000;">(</span>0, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>ix, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #ff0000; font-style: italic;">/*<br />
line_r(1, 0, (int)ix+1, (int)iy, MAGENTA);<br />
line_r(2, 0, (int)ix+2, (int)iy, MAGENTA);<br />
line_r(3, 0, (int)ix+3, (int)iy, MAGENTA);<br />
line_r(4, 0, (int)ix+4, (int)iy, MAGENTA);<br />
*/</span><br />
line_r<span style="color: #008000;">(</span>5, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>ix<span style="color: #000040;">+</span>5, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>0, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>ix, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #ff0000; font-style: italic;">/*<br />
line_r(-1, 0, (int)-ix-1, (int)iy, MAGENTA);<br />
line_r(-2, 0, (int)-ix-2, (int)iy, MAGENTA);<br />
line_r(-3, 0, (int)-ix-3, (int)iy, MAGENTA);<br />
line_r(-4, 0, (int)-ix-4, (int)iy, MAGENTA);<br />
*/</span><br />
line_r<span style="color: #008000;">(</span><span style="color: #000040;">-</span>5, 0, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span><span style="color: #000040;">-</span>ix<span style="color: #000040;">-</span>5, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>iy, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
draw_wheel<span style="color: #008000;">(</span><span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>x, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>y, <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span><span style="color: #008000;">)</span>radius, theta<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
swapbuffers<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #339900;">#endif </span><br />
twoT <span style="color: #000080;">=</span> <span style="color: #008000;">(</span>CLOCK<span style="color: #000040;">+</span>2<span style="color: #000040;">*</span>tick<span style="color: #008000;">)</span><span style="color: #000040;">*</span>CLOCK<span style="color: #008080;">;</span><br />
theta <span style="color: #000040;">-</span><span style="color: #000080;">=</span> speed<span style="color: #000040;">/</span>radius<span style="color: #000040;">*</span>CLOCK <span style="color: #000040;">-</span> C2<span style="color: #000040;">*</span>twoT<span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>theta <span style="color: #000080;"><=</span> <span style="color: #000040;">-</span>2.0f<span style="color: #000040;">*</span>PI<span style="color: #008000;">)</span> <span style="color: #008000;">{</span> theta <span style="color: #000040;">+</span><span style="color: #000080;">=</span> 2.0f<span style="color: #000040;">*</span>PI<span style="color: #008080;">;</span> <span style="color: #008000;">}</span><br />
x <span style="color: #000040;">+</span><span style="color: #000080;">=</span> <span style="color: #008000;">(</span>speed<span style="color: #000040;">*</span>CLOCK <span style="color: #000040;">-</span> C1<span style="color: #000040;">*</span>twoT<span style="color: #008000;">)</span><span style="color: #000040;">*</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
y <span style="color: #000040;">+</span><span style="color: #000080;">=</span> <span style="color: #008000;">(</span>speed<span style="color: #000040;">*</span>CLOCK <span style="color: #000040;">-</span> C1<span style="color: #000040;">*</span>twoT<span style="color: #008000;">)</span><span style="color: #000040;">*</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
tick <span style="color: #000040;">+</span><span style="color: #000080;">=</span> CLOCK<span style="color: #008080;">;</span><br />
<span style="color: #008000;">}</span> <span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>tick <span style="color: #000080;"><=</span> t<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
energy <span style="color: #000080;">=</span> g<span style="color: #000040;">*</span>h<span style="color: #008080;">;</span><br />
kr <span style="color: #000080;">=</span> h<span style="color: #000040;">+</span>radius<span style="color: #000040;">/</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span> <span style="color: #000040;">-</span> radius<span style="color: #000040;">*</span><span style="color: #008000;">(</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span> <span style="color: #000040;">-</span> <span style="color: #0000dd;">sin</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
br <span style="color: #000080;">=</span> kr <span style="color: #000040;">/</span> <span style="color: #0000dd;">tan</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
x <span style="color: #000080;">=</span> br <span style="color: #000040;">-</span> radius<span style="color: #000040;">*</span><span style="color: #008000;">(</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span> <span style="color: #000040;">+</span> <span style="color: #0000dd;">sin</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span> y <span style="color: #000080;">=</span> h<span style="color: #000040;">+</span>radius<span style="color: #000040;">/</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">(</span>angle<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
speed <span style="color: #000080;">=</span> <span style="color:#800080;">0.0f</span><span style="color: #008080;">;</span><br />
<span style="color: #008000;">}</span><br />
<span style="color: #008000;">}</span><br />
<span style="color: #339900;">#define _WHEEL</span><br />
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">(</span><span style="color: #0000ff;">void</span><span style="color: #008000;">)</span><br />
<span style="color: #008000;">{</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Enter Screen Size [Width, Height] : "</span><span style="color: #008080;">;</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cin</span> <span style="color: #000080;">>></span> _WIDTH <span style="color: #000080;">>></span> _HEIGHT<span style="color: #008080;">;</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Enter Center Coordinates [CX, CY] : "</span><span style="color: #008080;">;</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cin</span> <span style="color: #000080;">>></span> _CX <span style="color: #000080;">>></span> _CY<span style="color: #008080;">;</span><br />
initwindow<span style="color: #008000;">(</span>_WIDTH, _HEIGHT, <span style="color: #FF0000;">".:: WHEEL ROLLING ON AN INCLINED PLANE ::."</span>, 100, 100, <span style="color: #0000ff;">true</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
setbkcolor<span style="color: #008000;">(</span>WHITE<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
cleardevice<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
swapbuffers<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
cleardevice<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
swapbuffers<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #339900;">#ifdef _TEST_TRANSLATE</span><br />
<span style="color: #0000ff;">int</span> x0, y0, x1, y1, tx, ty<span style="color: #008080;">;</span><br />
<br />
line_r<span style="color: #008000;">(</span><span style="color: #000040;">-</span>_CX, 0, _WIDTH<span style="color: #000040;">-</span>_CX, 0, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>0, _CY, 0, <span style="color: #000040;">-</span>_HEIGHT<span style="color: #000040;">+</span>_CY, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
swapbuffers<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span><span style="color: #000040;">-</span>_CX, 0, _WIDTH<span style="color: #000040;">-</span>_CX, 0, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>0, _CY, 0, <span style="color: #000040;">-</span>_HEIGHT<span style="color: #000040;">+</span>_CY, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
swapbuffers<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
_TRANS <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Enter (x0, y0, x1, y1, tx, ty) [5000 to exit]: "</span><span style="color: #008080;">;</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cin</span> <span style="color: #000080;">>></span> x0<span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>x0 <span style="color: #000040;">!</span><span style="color: #000080;">=</span> 5000<span style="color: #008000;">)</span> <span style="color: #008000;">{</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cin</span> <span style="color: #000080;">>></span> y0 <span style="color: #000080;">>></span> x1 <span style="color: #000080;">>></span> y1 <span style="color: #000080;">>></span> tx <span style="color: #000080;">>></span> ty<span style="color: #008080;">;</span><br />
SetToIdentity<span style="color: #008000;">(</span>_M<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
Translate<span style="color: #008000;">(</span>_M, tx, ty<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>x0, y0, x1, y1, BLACK<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
swapbuffers<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>x0, y0, x1, y1, BLACK<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
swapbuffers<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Enter (x0, y0, x1, y1, tx, ty) [5000 to exit]: "</span><span style="color: #008080;">;</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cin</span> <span style="color: #000080;">>></span> x0<span style="color: #008080;">;</span><br />
<span style="color: #008000;">}</span><br />
<span style="color: #339900;">#endif // _TEST_TRANSLATE</span><br />
<br />
<span style="color: #339900;">#ifdef _TEST_WHEEL</span><br />
<span style="color: #0000ff;">int</span> xc, yc, r<span style="color: #008080;">;</span> <span style="color: #0000ff;">float</span> theta, radian<span style="color: #008080;">;</span><br />
<br />
line_r<span style="color: #008000;">(</span><span style="color: #000040;">-</span>_CX, 0, _WIDTH<span style="color: #000040;">-</span>_CX, 0, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>0, _CY, 0, <span style="color: #000040;">-</span>_HEIGHT<span style="color: #000040;">+</span>_CY, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
swapbuffers<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span><span style="color: #000040;">-</span>_CX, 0, _WIDTH<span style="color: #000040;">-</span>_CX, 0, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
line_r<span style="color: #008000;">(</span>0, _CY, 0, <span style="color: #000040;">-</span>_HEIGHT<span style="color: #000040;">+</span>_CY, MAGENTA<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
swapbuffers<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Enter (xc, yc, r, theta)[5000 to exit]: "</span><span style="color: #008080;">;</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cin</span> <span style="color: #000080;">>></span> xc<span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>xc <span style="color: #000040;">!</span><span style="color: #000080;">=</span> 5000<span style="color: #008000;">)</span> <span style="color: #008000;">{</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cin</span> <span style="color: #000080;">>></span> yc <span style="color: #000080;">>></span> r <span style="color: #000080;">>></span> theta<span style="color: #008080;">;</span><br />
radian <span style="color: #000080;">=</span> theta <span style="color: #000040;">/</span> 180.0f <span style="color: #000040;">*</span> <span style="color:#800080;">3.14159f</span><span style="color: #008080;">;</span><br />
draw_wheel<span style="color: #008000;">(</span>xc, yc, r, radian<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
swapbuffers<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
draw_wheel<span style="color: #008000;">(</span>xc, yc, r, radian<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
swapbuffers<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Enter (xc, yc, r, theta)[5000 to exit]: "</span><span style="color: #008080;">;</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cin</span> <span style="color: #000080;">>></span> xc<span style="color: #008080;">;</span><br />
<span style="color: #008000;">}</span><br />
<br />
<span style="color: #339900;">#endif // _TEST_WHEEL</span><br />
<br />
<span style="color: #339900;">#ifdef _WHEEL</span><br />
<span style="color: #0000ff;">float</span> theta, gravity<span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">int</span> radius<span style="color: #008080;">;</span><br />
<br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Enter radius of wheel [5000 to exit]: "</span><span style="color: #008080;">;</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cin</span> <span style="color: #000080;">>></span> radius<span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">while</span><span style="color: #008000;">(</span>radius <span style="color: #000040;">!</span><span style="color: #000080;">=</span> 5000<span style="color: #008000;">)</span> <span style="color: #008000;">{</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Enter inclination angle of plane: "</span><span style="color: #008080;">;</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cin</span> <span style="color: #000080;">>></span> theta<span style="color: #008080;">;</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Enter gravity constant of planet (980 for earth)[unit is cm/s2]: "</span><span style="color: #008080;">;</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cin</span> <span style="color: #000080;">>></span> gravity<span style="color: #008080;">;</span><br />
<br />
simulate<span style="color: #008000;">(</span>theta <span style="color: #000040;">/</span> 180.0f <span style="color: #000040;">*</span> 3.14159f, radius, gravity<span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Enter radius of wheel [5000 to exit]: "</span><span style="color: #008080;">;</span><br />
std<span style="color: #008080;">::</span><span style="color: #0000dd;">cin</span> <span style="color: #000080;">>></span> radius<span style="color: #008080;">;</span><br />
<span style="color: #008000;">}</span><br />
<span style="color: #339900;">#endif // _WHEEL </span><br />
<br />
closegraph<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
restorecrtmode<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span><br />
<span style="color: #008000;">}</span><br />
</div>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com1tag:blogger.com,1999:blog-4276715425787171951.post-29708192462402662662009-09-29T11:36:00.000+05:302009-09-29T11:36:00.087+05:30Teach Yourself Programming in Ten Years (Peter Norvig)<h2>Why is everyone in such a rush?</h2>Walk into any bookstore, and you'll see how to <i>Teach Yourself Java in 7 Days</i> alongside endless variations offering to teach Visual Basic, Windows, the Internet, and so on in a few days or hours. I did the following <a href="http://www.amazon.com/exec/obidos/tg/browse/-/468558/104-5938873-6579160">power search</a> at <a href="http://www.amazon.com/">Amazon.com</a>: <pre><a href="http://www.amazon.com/exec/obidos/search-handle-url/ix=books&rank=%2Bfeaturedrank&fqp=power%01pubdate%3A%20after%201992%20and%20title%3A%20days%20and%0D%20%28title%3A%20learn%20or%20title%3A%20teach%20yourself%29&sz=25&pg=1/ref=s_b_np">pubdate: after 1992 and title: days and</a>
<a href="http://www.amazon.com/exec/obidos/search-handle-url/ix=books&rank=%2Bfeaturedrank&fqp=power%01pubdate%3A%20after%201992%20and%20title%3A%20days%20and%0D%20%28title%3A%20learn%20or%20title%3A%20teach%20yourself%29&sz=25&pg=1/ref=s_b_np">(title: learn or title: teach yourself)</a></pre>and got back 248 hits. The first 78 were computer books (number 79 was <a href="http://www.amazon.com/exec/obidos/ASIN/0781802245/"><i>Learn Bengali in 30 days</i></a>). I replaced "days" with <a href="http://www.amazon.com/exec/obidos/search-handle-url/ix=books&rank=%2Bfeaturedrank&fqp=power%01pubdate%3A%20after%201992%20and%20title%3A%20hours%20and%0D%20%28title%3A%20learn%20or%20title%3A%20teach%20yourself%29&sz=25&pg=3/ref=s_b_np">"hours"</a> and got remarkably similar results: 253 more books, with 77 computer books followed by <a href="http://www.amazon.com/exec/obidos/ASIN/0028638999/"><i>Teach Yourself Grammar and Style in 24 Hours</i></a> at number 78. Out of the top 200 total, 96% were computer books. The conclusion is that either people are in a big rush to learn about computers, or that computers are somehow fabulously easier to learn than anything else. There are no books on how to learn Beethoven, or Quantum Physics, or even Dog Grooming in a few days. Felleisen <i>et al.</i> give a nod to this trend in their book <i><a href="http://www.ccs.neu.edu/home/matthias/HtDP2e/index.html">How to Design Programs</a></i>, when they say "Bad programming is easy. <i>Idiots</i> can learn it in <i>21 days</i>, even if they are <i>dummies</i>. <br />
Let's analyze what a title like <i><a href="http://www.amazon.com/Learn-C-Three-Days-Rachele/dp/1556227078">Learn C++ in Three Days</a></i> could mean: <br />
<ul><li><b>Learn:</b> In 3 days you won't have time to write several significant programs, and learn from your successes and failures with them. You won't have time to work with an experienced programmer and understand what it is like to live in a C++ environment. In short, you won't have time to learn much. So the book can only be talking about a superficial familiarity, not a deep understanding. As Alexander Pope said, a little learning is a dangerous thing. <br />
</li>
<li><b>C++:</b> In 3 days you might be able to learn some of the syntax of C++ (if you already know another language), but you couldn't learn much about how to use the language. In short, if you were, say, a Basic programmer, you could learn to write programs in the style of Basic using C++ syntax, but you couldn't learn what C++ is actually good (and bad) for. So what's the point? <a href="http://www-pu.informatik.uni-tuebingen.de/users/klaeren/epigrams.html">Alan Perlis</a> once said: "A language that doesn't affect the way you think about programming, is not worth knowing". One possible point is that you have to learn a tiny bit of C++ (or more likely, something like JavaScript or Flash's Flex) because you need to interface with an existing tool to accomplish a specific task. But then you're not learning how to program; you're learning to accomplish that task. <br />
</li>
<li><b>in Three Days:</b> Unfortunately, this is not enough, as the next section shows. </li>
</ul><h2>Teach Yourself Programming in Ten Years</h2>Researchers (<a href="http://www.amazon.com/exec/obidos/ASIN/034531509X/">Bloom (1985)</a>, <a href="http://norvig.com/21-days.html#bh">Bryan & Harter (1899)</a>, <a href="http://www.amazon.com/exec/obidos/ASIN/0805803092">Hayes (1989)</a>, <a href="http://norvig.com/21-days.html#sc">Simmon & Chase (1973)</a>) have shown it takes about ten years to develop expertise in any of a wide variety of areas, including chess playing, music composition, telegraph operation, painting, piano playing, swimming, tennis, and research in neuropsychology and topology. The key is <i>deliberative</i> practice: not just doing it again and again, but challenging yourself with a task that is just beyond your current ability, trying it, analyzing your performance while and after doing it, and correcting any mistakes. Then repeat. And repeat again. There appear to be no real shortcuts: even Mozart, who was a musical prodigy at age 4, took 13 more years before he began to produce world-class music. In another genre, the Beatles seemed to burst onto the scene with a string of #1 hits and an appearance on the Ed Sullivan show in 1964. But they had been playing small clubs in Liverpool and Hamburg since 1957, and while they had mass appeal early on, their first great critical success, <i>Sgt. Peppers</i>, was released in 1967. <a href="http://www.amazon.com/Outliers-Story-Success-Malcolm-Gladwell/dp/0316017922">Malcolm Gladwell</a> reports that a study of students at the Berlin Academy of Music compared the top, middle, and bottom third of the class and asked them how much they had practiced: <blockquote> Everyone, from all three groups, started playing at roughly the same time - around the age of five. In those first few years, everyone practised roughly the same amount - about two or three hours a week. But around the age of eight real differences started to emerge. The students who would end up as the best in their class began to practise more than everyone else: six hours a week by age nine, eight by age 12, 16 a week by age 14, and up and up, until by the age of 20 they were practising well over 30 hours a week. By the age of 20, the elite performers had all totalled 10,000 hours of practice over the course of their lives. The merely good students had totalled, by contrast, 8,000 hours, and the future music teachers just over 4,000 hours. </blockquote>So it may be that 10,000 hours, not 10 years, is the magic number. Samuel Johnson (1709-1784) thought it took longer: "Excellence in any department can be attained only by the labor of a lifetime; it is not to be purchased at a lesser price." And Chaucer (1340-1400) complained "the lyf so short, the craft so long to lerne." Hippocrates (c. 400BC) is known for the excerpt "ars longa, vita brevis", which is part of the longer quotation "Ars longa, vita brevis, occasio praeceps, experimentum periculosum, iudicium difficile", which in English renders as "Life is short, [the] craft long, opportunity fleeting, experiment treacherous, judgment difficult." Although in Latin, <i>ars</i> can mean either art or craft, in the original Greek the word "techne" can only mean "skill", not "art". <br />
Here's my recipe for programming success: <br />
<ul><li> Get interested in programming, and do some because it is fun. Make sure that it keeps being enough fun so that you will be willing to put in ten years. <br />
</li>
<li> Talk to other programmers; read other programs. This is more important than any book or training course. <br />
</li>
<li> Program. The best kind of learning is <a href="http://www.engines4ed.org/hyperbook/nodes/NODE-120-pg.html">learning by doing</a>. To put it more technically, "the maximal level of performance for individuals in a given domain is not attained automatically as a function of extended experience, but the level of performance can be increased even by highly experienced individuals as a result of deliberate efforts to improve." <a href="http://www2.umassd.edu/swpi/DesignInCS/expertise.html">(p. 366)</a> and "the most effective learning requires a well-defined task with an appropriate difficulty level for the particular individual, informative feedback, and opportunities for repetition and corrections of errors." (p. 20-21) The book <i> <a href="http://www.amazon.com/exec/obidos/ASIN/0521357349">Cognition in Practice: Mind, Mathematics, and Culture in Everyday Life</a></i> is an interesting reference for this viewpoint. <br />
</li>
<li> If you want, put in four years at a college (or more at a graduate school). This will give you access to some jobs that require credentials, and it will give you a deeper understanding of the field, but if you don't enjoy school, you can (with some dedication) get similar experience on the job. In any case, book learning alone won't be enough. "Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter" says Eric Raymond, author of <i>The New Hacker's Dictionary</i>. One of the best programmers I ever hired had only a High School degree; he's produced a lot of <a href="http://www.xemacs.org/">great</a> <a href="http://www.mozilla.org/">software</a>, has his own <a href="http://groups.google.com/groups?q=alt.fan.jwz&meta=site%3Dgroups">news group</a>, and made enough in stock options to buy his own <a href="http://en.wikipedia.org/wiki/DNA_Lounge">nightclub</a>. </li>
<li> Work on projects with other programmers. Be the best programmer on some projects; be the worst on some others. When you're the best, you get to test your abilities to lead a project, and to inspire others with your vision. When you're the worst, you learn what the masters do, and you learn what they don't like to do (because they make you do it for them). <br />
</li>
<li> Work on projects <i>after</i> other programmers. Be involved in understanding a program written by someone else. See what it takes to understand and fix it when the original programmers are not around. Think about how to design your programs to make it easier for those who will maintain it after you. <br />
</li>
<li> Learn at least a half dozen programming languages. Include one language that supports class abstractions (like Java or C++), one that supports functional abstraction (like Lisp or ML), one that supports syntactic abstraction (like Lisp), one that supports declarative specifications (like Prolog or C++ templates), one that supports coroutines (like Icon or Scheme), and one that supports parallelism (like Sisal). <br />
</li>
<li> Remember that there is a "computer" in "computer science". Know how long it takes your computer to execute an instruction, fetch a word from memory (with and without a cache miss), read consecutive words from disk, and seek to a new location on disk. (<a href="http://norvig.com/21-days.html#answers">Answers here.</a>) <br />
</li>
<li> Get involved in a language standardization effort. It could be the ANSI C++ committee, or it could be deciding if your local coding style will have 2 or 4 space indentation levels. Either way, you learn about what other people like in a language, how deeply they feel so, and perhaps even a little about why they feel so. <br />
</li>
<li> Have the good sense to get off the language standardization effort as quickly as possible. </li>
</ul>With all that in mind, its questionable how far you can get just by book learning. Before my first child was born, I read all the <i>How To</i> books, and still felt like a clueless novice. 30 Months later, when my second child was due, did I go back to the books for a refresher? No. Instead, I relied on my personal experience, which turned out to be far more useful and reassuring to me than the thousands of pages written by experts. Fred Brooks, in his essay <i><a href="http://en.wikipedia.org/wiki/No_Silver_Bullet">No Silver Bullet</a></i> identified a three-part plan for finding great software designers: <br />
<ol><li>Systematically identify top designers as early as possible. <br />
</li>
<li>Assign a career mentor to be responsible for the development of the prospect and carefully keep a career file. <br />
</li>
<li>Provide opportunities for growing designers to interact and stimulate each other. <br />
</li>
</ol>This assumes that some people already have the qualities necessary for being a great designer; the job is to properly coax them along. <a href="http://www-pu.informatik.uni-tuebingen.de/users/klaeren/epigrams.html">Alan Perlis</a> put it more succinctly: "Everyone can be taught to sculpt: Michelangelo would have had to be taught how not to. So it is with the great programmers". So go ahead and buy that Java book; you'll probably get some use out of it. But you won't change your life, or your real overall expertise as a programmer in 24 hours, days, or even months. <br />
<br />
<hr /> <h2>References</h2>Bloom, Benjamin (ed.) <i><a href="http://www.amazon.com/exec/obidos/ASIN/034531509X">Developing Talent in Young People</a></i>, Ballantine, 1985. <br />
Brooks, Fred, <i><a href="http://citeseer.nj.nec.com/context/7718/0">No Silver Bullets</a></i>, IEEE Computer, vol. 20, no. 4, 1987, p. 10-19. <br />
<a href="" name="bh">Bryan, W.L. & Harter, N. "Studies on the telegraphic language: The acquisition of a hierarchy of habits. <i>Psychology Review</i>, 1899, 8, 345-375</a> <br />
Hayes, John R., <i><a href="http://www.amazon.com/exec/obidos/ASIN/0805803092">Complete Problem Solver</a></i> Lawrence Erlbaum, 1989. <br />
<a href="" name="cs">Chase, William G. & Simon, Herbert A. </a><a href="http://books.google.com/books?id=dYPSHAAACAAJ&dq=%22perception+in+chess%22+simon&ei=z4PyR5iIAZnmtQPbyLyuDQ">"Perception in Chess"</a> <i>Cognitive Psychology</i>, 1973, 4, 55-81. <br />
Lave, Jean, <i><a href="http://www.amazon.com/exec/obidos/ASIN/0521357349">Cognition in Practice: Mind, Mathematics, and Culture in Everyday Life</a></i>, Cambridge University Press, 1988. <br />
<hr /> <a href="" name="answers"><h2>Answers</h2></a> Approximate timing for various operations on a typical 1GHz PC in 2001: <br />
<table border="1" cellpadding="2" cellspacing="2"><tbody>
<tr><td>execute single instruction </td><td> 1 nanosec = (1/1,000,000,000) sec </td></tr>
<tr><td>fetch word from L1 cache memory </td><td> 2 nanosec </td></tr>
<tr><td>fetch word from main memory </td><td> 10 nanosec </td></tr>
<tr><td>fetch word from consecutive disk location </td><td> 200 nanosec </td></tr>
<tr><td>fetch word from new disk location (seek) </td><td> 8,000,000 nanosec = 8 millisec </td></tr>
</tbody></table><hr /> <h2>Appendix: Language Choice</h2>Several people have asked what programming language they should learn first. There is no one answer, but consider these points: <br />
<ul><li><i>Use your friends</i>. When asked "what operating system should I use, Windows, Unix, or Mac?", my answer is usually: "use whatever your friends use." The advantage you get from learning from your friends will offset any intrinsic difference between OS, or between programming languages. Also consider your future friends: the community of programmers that you will be a part of if you continue. Does your chosen language have a large growing community or a small dying one? Are there books, web sites, and online forums to get answers from? Do you like the people in those forums? </li>
<li><i>Keep it simple</i>. Programming languages such as C++ and Java are designed for professional development by large teams of experienced programmers who are concerned about the run-time efficiency of their code. As a result, these languages have complicated parts designed for these circumstances. You're concerned with learning to program. You don't need that complication. You want a language that was designed to be easy to learn and remember by a single new programmer. </li>
<li><i>Play.</i> Which way would you rather learn to play the piano: the normal, interactive way, in which you hear each note as soon as you hit a key, or "batch" mode, in which you only hear the notes after you finish a whole song? Clearly, interactive mode makes learning easier for the piano, and also for programming. Insist on a language with an interactive mode and use it. </li>
</ul>Given these criteria, my recommendations for a first programming language would be <b><a href="http://python.org/">Python</a></b> or <b><a href="http://www.schemers.org/">Scheme</a></b>. But your circumstances may vary, and there are other good choices. If your age is a single-digit, you might prefer <a href="http://alice.org/">Alice</a> or <a href="http://www.squeak.org/">Squeak</a> (older learners might also enjoy these). The important thing is that you choose and get started. <hr /> <h2>Appendix: Books and Other Resources</h2>Several people have asked what books and web pages they should learn from. I repeat that "book learning alone won't be enough" but I can recommend the following: <br />
<ul><li> <b>Scheme:</b> <a href="http://www.amazon.com/gp/product/0262011530">Structure and Interpretation of Computer Programs (Abelson & Sussman)</a> is probably the best introduction to computer science, and it does teach programming as a way of understanding the computer science. You can see <a href="http://www.swiss.ai.mit.edu/classes/6.001/abelson-sussman-lectures/">online videos of lectures</a> on this book, as well as the <a href="http://mitpress.mit.edu/sicp/full-text/book/book.html">complete text online</a>. The book is challenging and will weed out some people who perhaps could be successful with another approach. </li>
<li> <b>Scheme:</b> <a href="http://www.amazon.com/gp/product/0262062186">How to Design Programs (Felleisen <i>et al.</i>)</a> is one of the best books on how to actually design programs in an elegant and functional way. </li>
<li> <b>Python:</b> <a href="http://www.amazon.com/gp/product/1887902996">Python Programming: An Intro to CS (Zelle)</a> is a good introduction using Python. </li>
<li> <b>Python:</b> Several online <a href="http://wiki.python.org/moin/BeginnersGuide">tutorials</a> are available at <a href="http://python.org/">Python.org</a>. </li>
<li> <b>Oz:</b> <a href="http://www.amazon.com/gp/product/0262220695">Concepts, Techniques, and Models of Computer Programming (Van Roy & Haridi)</a> is seen by some as the modern-day successor to Abelson & Sussman. It is a tour through the big ideas of programming, covering a wider range than Abelson & Sussman while being perhaps easier to read and follow. It uses a language, Oz, that is not widely known but serves as a basis for learning other languages. </li>
</ul><br />
<hr /> <h2>Notes</h2>T. Capey points out that the <a href="http://www.amazon.com/exec/obidos/ASIN/0805803092">Complete Problem Solver</a> page on Amazon now has the "Teach Yourself Bengali in 21 days" and "Teach Yourself Grammar and Style" books under the "Customers who shopped for this item also shopped for these items" section. I guess that a large portion of the people who look at that book are coming from this page. Thanks to Ross Cohen for help with Hippocrates. <br />
<br />
_______________________________________________________________________________ <br />
<br />
<a href="http://norvig.com/index.html"><i>Peter Norvig</i> (Copyright 2001)</a>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com0tag:blogger.com,1999:blog-4276715425787171951.post-88423671077958437902009-09-29T11:28:00.001+05:302009-09-29T11:38:04.094+05:30How To Become A Hacker (Eric Steven Raymond)<div class="toc"><b>Table of Contents</b><br />
<dl><dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#why_this">Why This Document?</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#what_is">What Is a Hacker?</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#attitude">The Hacker Attitude</a></dt>
<dd>
<dl><dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#believe1">1. The world is full of fascinating problems waiting to be solved.</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#believe2">2. No problem should ever have to be solved twice.</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#believe3">3. Boredom and drudgery are evil.</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#believe4">4. Freedom is good.</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#believe5">5. Attitude is no substitute for competence.</a></dt>
</dl></dd><br />
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#basic_skills">Basic Hacking Skills</a></dt><br />
<br />
<br />
<dd><br />
<dl><dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#skills1">1. Learn how to program.</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#skills2">2. Get one of the open-source Unixes and learn to use and run it.</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#skills3">3. Learn how to use the World Wide Web and write HTML.</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#skills4">4. If you don't have functional English, learn it.</a></dt>
</dl></dd><br />
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#status">Status in the Hacker Culture</a></dt><br />
<br />
<br />
<dd><br />
<dl><dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#respect1">1. Write open-source software</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#respect2">2. Help test and debug open-source software</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#respect3">3. Publish useful information</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#respect4">4. Help keep the infrastructure working</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#respect5">5. Serve the hacker culture itself</a></dt>
</dl></dd><br />
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#nerd_connection">The Hacker/Nerd Connection</a></dt><br />
<br />
<br />
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#style">Points For Style</a></dt><br />
<br />
<br />
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#resources">Other Resources</a></dt><br />
<br />
<br />
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#FAQ">Frequently Asked Questions</a></dt><br />
<br />
<br />
</dl></div><div class="mediaobject"><img src="http://www.catb.org/%7Eesr/faqs/glider.png" /><br />
</div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both;">Why This Document?</h2></div></div></div>As editor of the <a class="ulink" href="http://www.catb.org/jargon" target="_top">Jargon File</a> and author of a few other well-known documents of similar nature, I often get email requests from enthusiastic network newbies asking (in effect) "how can I learn to be a wizardly hacker?". Back in 1996 I noticed that there didn't seem to be any other FAQs or web documents that addressed this vital question, so I started this one. A lot of hackers now consider it definitive, and I suppose that means it is. Still, I don't claim to be the exclusive authority on this topic; if you don't like what you read here, write your own.<br />
If you are reading a snapshot of this document offline, the current version lives at <a class="ulink" href="http://catb.org/%7Eesr/faqs/hacker-howto.html" target="_top"> http://catb.org/~esr/faqs/hacker-howto.html</a>.<br />
Note: there is a list of <a class="link" href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#FAQ" title="Frequently Asked Questions">Frequently Asked Questions</a> at the end of this document. Please read these—twice—before mailing me any questions about this document.<br />
Numerous translations of this document are available: <a class="ulink" href="http://www.slashproc.net/doc/howto-ar.html" target="_top">Arabic</a> <a class="ulink" href="ftp://download.yovko.net/pub/mirrors/linuxcenter/html/paper/hackers.html" target="_top">Bulgarian</a>, <a class="ulink" href="http://arfues.net/traduccions/hacker-howto/hacker-howto.html" target="_top">Catalan</a>, <a class="ulink" href="http://www.angelfire.com/ok/leekawo/hackersim.htm" target="_top">Chinese (Simplified)</a>, <a class="ulink" href="http://www.olemichaelsen.dk/hacker-howto.html" target="_top">Danish</a>, <a class="ulink" href="http://www.knudde.be/index.php?page_name=hacker_howto" target="_top">Dutch</a>, <a class="ulink" href="http://www.kakupesa.net/hacker/" target="_top">Estonian</a>, <a class="ulink" href="http://htbh.meisam.info/" target="_top">Farsi</a>, <a class="ulink" href="http://hack.fi/hacker-howto-fi.php" target="_top">Finnish</a>, <a class="ulink" href="http://www.linuxtaskforce.de/hacker-howto-ger.html" target="_top">German</a>, <a class="ulink" href="http://users.otenet.gr/%7Eindy90/hacker-howto-gr/" target="_top">Greek</a> <a class="ulink" href="http://www.rootshell.be/%7Eeg/faqs/hacker-howto.heb.html" target="_top">Hebrew</a>, <a class="ulink" href="http://www.saltatempo.org/hacker/hacker.php" target="_top">Italian</a> <a class="ulink" href="http://webagora.idd.tamabi.ac.jp/wiki/index.php?cmd=read&page=HowToBecomeAHacker" target="_top">Japanese</a>, <a class="ulink" href="http://stian.atlantiscrew.net/doc/hacker-howto.html" target="_top">Norwegian</a>, <a class="ulink" href="http://tpk.f2o.org/hacker-howto.html" target="_top">Polish</a>, <a class="ulink" href="http://jvdm.freeshell.org/pt/raquer-howto/" target="_top">Portuguese (Brazilian)</a>, <a class="ulink" href="http://garaj.xhost.ro/hacker-howto/hacker-howto.ro.htm" target="_top">Romanian</a> <a class="ulink" href="http://lafox.net/docs/Hacker-HOWTO.html" target="_top">Russian</a> <a class="ulink" href="http://www.sindominio.net/biblioweb/telematica/hacker-como.html" target="_top">Spanish</a>, <a class="ulink" href="http://www.belgeler.org/howto/hacker-howto/hacker-howto.html" target="_top">Turkish</a>, and <a class="ulink" href="http://www1.tripnet.se/%7Emly/open/faqs/hacker-howto.se.html" target="_top">Swedish</a>. Note that since this document changes occasionally, they may be out of date to varying degrees. <br />
The five-dots-in-nine-squares diagram that decorates this document is called a <i>glider</i>. It is a simple pattern with some surprising properties in a mathematical simulation called <a class="ulink" href="http://dmoz.org/Computers/Artificial_Life/Cellular_Automata/" target="_top">Life</a> that has fascinated hackers for many years. I think it makes a good visual emblem for what hackers are like — abstract, at first a bit mysterious-seeming, but a gateway to a whole world with an intricate logic of its own. Read more about the glider emblem <a class="ulink" href="http://www.catb.org/%7Eesr/hacker-emblem/" target="_top">here</a>.<br />
</div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both;">What Is a Hacker?</h2></div></div></div>The <a class="ulink" href="http://www.catb.org/jargon" target="_top">Jargon File</a> contains a bunch of definitions of the term ‘hacker’, most having to do with technical adeptness and a delight in solving problems and overcoming limits. If you want to know how to <i>become</i> a hacker, though, only two are really relevant.<br />
There is a community, a shared culture, of expert programmers and networking wizards that traces its history back through decades to the first time-sharing minicomputers and the earliest ARPAnet experiments. The members of this culture originated the term ‘hacker’. Hackers built the Internet. Hackers made the Unix operating system what it is today. Hackers run Usenet. Hackers make the World Wide Web work. If you are part of this culture, if you have contributed to it and other people in it know who you are and call you a hacker, you're a hacker.<br />
The hacker mind-set is not confined to this software-hacker culture. There are people who apply the hacker attitude to other things, like electronics or music — actually, you can find it at the highest levels of any science or art. Software hackers recognize these kindred spirits elsewhere and may call them ‘hackers’ too — and some claim that the hacker nature is really independent of the particular medium the hacker works in. But in the rest of this document we will focus on the skills and attitudes of software hackers, and the traditions of the shared culture that originated the term ‘hacker’.<br />
There is another group of people who loudly call themselves hackers, but aren't. These are people (mainly adolescent males) who get a kick out of breaking into computers and phreaking the phone system. Real hackers call these people ‘crackers’ and want nothing to do with them. Real hackers mostly think crackers are lazy, irresponsible, and not very bright, and object that being able to break security doesn't make you a hacker any more than being able to hotwire cars makes you an automotive engineer. Unfortunately, many journalists and writers have been fooled into using the word ‘hacker’ to describe crackers; this irritates real hackers no end.<br />
The basic difference is this: hackers build things, crackers break them.<br />
If you want to be a hacker, keep reading. If you want to be a cracker, go read the <a class="ulink" href="news:alt.2600" target="_top">alt.2600</a> newsgroup and get ready to do five to ten in the slammer after finding out you aren't as smart as you think you are. And that's all I'm going to say about crackers.<br />
<div class="mediaobject"><img src="http://www.catb.org/%7Eesr/faqs/glider.png" /><br />
</div></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both;">The Hacker Attitude</h2></div></div></div><div class="toc"><br />
<dl><dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#believe1">1. The world is full of fascinating problems waiting to be solved.</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#believe2">2. No problem should ever have to be solved twice.</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#believe3">3. Boredom and drudgery are evil.</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#believe4">4. Freedom is good.</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#believe5">5. Attitude is no substitute for competence.</a></dt>
</dl></div>Hackers solve problems and build things, and they believe in freedom and voluntary mutual help. To be accepted as a hacker, you have to behave as though you have this kind of attitude yourself. And to behave as though you have the attitude, you have to really believe the attitude.<br />
But if you think of cultivating hacker attitudes as just a way to gain acceptance in the culture, you'll miss the point. Becoming the kind of person who believes these things is important for <i>you</i> — for helping you learn and keeping you motivated. As with all creative arts, the most effective way to become a master is to imitate the mind-set of masters — not just intellectually but emotionally as well.<br />
Or, as the following modern Zen poem has it:<br />
<div class="literallayout"><br />
To follow the path:<br />
look to the master,<br />
follow the master,<br />
walk with the master,<br />
see through the master,<br />
become the master.<br />
<br />
</div>So, if you want to be a hacker, repeat the following things until you believe them:<br />
<div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title">1. The world is full of fascinating problems waiting to be solved.</h3></div></div></div>Being a hacker is lots of fun, but it's a kind of fun that takes lots of effort. The effort takes motivation. Successful athletes get their motivation from a kind of physical delight in making their bodies perform, in pushing themselves past their own physical limits. Similarly, to be a hacker you have to get a basic thrill from solving problems, sharpening your skills, and exercising your intelligence.<br />
If you aren't the kind of person that feels this way naturally, you'll need to become one in order to make it as a hacker. Otherwise you'll find your hacking energy is sapped by distractions like sex, money, and social approval.<br />
(You also have to develop a kind of faith in your own learning capacity — a belief that even though you may not know all of what you need to solve a problem, if you tackle just a piece of it and learn from that, you'll learn enough to solve the next piece — and so on, until you're done.)<br />
</div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title">2. No problem should ever have to be solved twice.</h3></div></div></div>Creative brains are a valuable, limited resource. They shouldn't be wasted on re-inventing the wheel when there are so many fascinating new problems waiting out there.<br />
To behave like a hacker, you have to believe that the thinking time of other hackers is precious — so much so that it's almost a moral duty for you to share information, solve problems and then give the solutions away just so other hackers can solve <i>new</i> problems instead of having to perpetually re-address old ones.<br />
Note, however, that "No problem should ever have to be solved twice." does not imply that you have to consider all existing solutions sacred, or that there is only one right solution to any given problem. Often, we learn a lot about the problem that we didn't know before by studying the first cut at a solution. It's OK, and often necessary, to decide that we can do better. What's not OK is artificial technical, legal, or institutional barriers (like closed-source code) that prevent a good solution from being re-used and <i>force</i> people to re-invent wheels.<br />
(You don't have to believe that you're obligated to give <i>all</i> your creative product away, though the hackers that do are the ones that get most respect from other hackers. It's consistent with hacker values to sell enough of it to keep you in food and rent and computers. It's fine to use your hacking skills to support a family or even get rich, as long as you don't forget your loyalty to your art and your fellow hackers while doing it.)<br />
</div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title">3. Boredom and drudgery are evil.</h3></div></div></div>Hackers (and creative people in general) should never be bored or have to drudge at stupid repetitive work, because when this happens it means they aren't doing what only they can do — solve new problems. This wastefulness hurts everybody. Therefore boredom and drudgery are not just unpleasant but actually evil.<br />
To behave like a hacker, you have to believe this enough to want to automate away the boring bits as much as possible, not just for yourself but for everybody else (especially other hackers).<br />
(There is one apparent exception to this. Hackers will sometimes do things that may seem repetitive or boring to an observer as a mind-clearing exercise, or in order to acquire a skill or have some particular kind of experience you can't have otherwise. But this is by choice — nobody who can think should ever be forced into a situation that bores them.)<br />
</div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title">4. Freedom is good.</h3></div></div></div>Hackers are naturally anti-authoritarian. Anyone who can give you orders can stop you from solving whatever problem you're being fascinated by — and, given the way authoritarian minds work, will generally find some appallingly stupid reason to do so. So the authoritarian attitude has to be fought wherever you find it, lest it smother you and other hackers.<br />
(This isn't the same as fighting all authority. Children need to be guided and criminals restrained. A hacker may agree to accept some kinds of authority in order to get something he wants more than the time he spends following orders. But that's a limited, conscious bargain; the kind of personal surrender authoritarians want is not on offer.)<br />
Authoritarians thrive on censorship and secrecy. And they distrust voluntary cooperation and information-sharing — they only like ‘cooperation’ that they control. So to behave like a hacker, you have to develop an instinctive hostility to censorship, secrecy, and the use of force or deception to compel responsible adults. And you have to be willing to act on that belief.<br />
</div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title">5. Attitude is no substitute for competence.</h3></div></div></div>To be a hacker, you have to develop some of these attitudes. But copping an attitude alone won't make you a hacker, any more than it will make you a champion athlete or a rock star. Becoming a hacker will take intelligence, practice, dedication, and hard work.<br />
Therefore, you have to learn to distrust attitude and respect competence of every kind. Hackers won't let posers waste their time, but they worship competence — especially competence at hacking, but competence at anything is valued. Competence at demanding skills that few can master is especially good, and competence at demanding skills that involve mental acuteness, craft, and concentration is best.<br />
If you revere competence, you'll enjoy developing it in yourself — the hard work and dedication will become a kind of intense play rather than drudgery. That attitude is vital to becoming a hacker.<br />
<div class="mediaobject"><img src="http://www.catb.org/%7Eesr/faqs/glider.png" /><br />
</div></div></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both;">Basic Hacking Skills</h2></div></div></div><div class="toc"><br />
<dl><dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#skills1">1. Learn how to program.</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#skills2">2. Get one of the open-source Unixes and learn to use and run it.</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#skills3">3. Learn how to use the World Wide Web and write HTML.</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#skills4">4. If you don't have functional English, learn it.</a></dt>
</dl></div>The hacker attitude is vital, but skills are even more vital. Attitude is no substitute for competence, and there's a certain basic toolkit of skills which you have to have before any hacker will dream of calling you one.<br />
This toolkit changes slowly over time as technology creates new skills and makes old ones obsolete. For example, it used to include programming in machine language, and didn't until recently involve HTML. But right now it pretty clearly includes the following:<br />
<div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title">1. Learn how to program.</h3></div></div></div>This, of course, is the fundamental hacking skill. If you don't know any computer languages, I recommend starting with Python. It is cleanly designed, well documented, and relatively kind to beginners. Despite being a good first language, it is not just a toy; it is very powerful and flexible and well suited for large projects. I have written a more detailed <a class="ulink" href="http://www.linuxjournal.com/article.php?sid=3882" target="_top">evaluation of Python</a>. Good <a class="ulink" href="http://docs.python.org/tut/tut.html" target="_top"> tutorials</a> are available at the <a class="ulink" href="http://docs.python.org/tutorial/" target="_top">Python web site</a>.<br />
I used to recommend Java as a good language to learn early, but <a class="ulink" href="http://www.stsc.hill.af.mil/CrossTalk/2008/01/0801DewarSchonberg.html" target="_top">this critique</a> has changed my mind (search for “The Pitfalls of Java as a First Programming Language” within it). A hacker cannot, as they devastatingly put it “approach problem-solving like a plumber in a hardware store”; you have to know what the components actually <i>do</i>. Now I think it is probably best to learn C and Lisp first, then Java.<br />
If you get into serious programming, you will have to learn C, the core language of Unix. C++ is very closely related to C; if you know one, learning the other will not be difficult. Neither language is a good one to try learning as your first, however. And, actually, the more you can avoid programming in C the more productive you will be.<br />
C is very efficient, and very sparing of your machine's resources. Unfortunately, C gets that efficiency by requiring you to do a lot of low-level management of resources (like memory) by hand. All that low-level code is complex and bug-prone, and will soak up huge amounts of your time on debugging. With today's machines as powerful as they are, this is usually a bad tradeoff — it's smarter to use a language that uses the machine's time less efficiently, but your time much <i>more</i> efficiently. Thus, Python.<br />
Other languages of particular importance to hackers include <a class="ulink" href="http://www.perl.com/" target="_top">Perl</a> and <a class="ulink" href="http://www.lisp.org/" target="_top">LISP</a>. Perl is worth learning for practical reasons; it's very widely used for active web pages and system administration, so that even if you never write Perl you should learn to read it. Many people use Perl in the way I suggest you should use Python, to avoid C programming on jobs that don't require C's machine efficiency. You will need to be able to understand their code.<br />
LISP is worth learning for a different reason — the profound enlightenment experience you will have when you finally get it. That experience will make you a better programmer for the rest of your days, even if you never actually use LISP itself a lot. (You can get some beginning experience with LISP fairly easily by writing and modifying editing modes for the Emacs text editor, or Script-Fu plugins for the GIMP.)<br />
It's best, actually, to learn all five of Python, C/C++, Java, Perl, and LISP. Besides being the most important hacking languages, they represent very different approaches to programming, and each will educate you in valuable ways.<br />
But be aware that you won't reach the skill level of a hacker or even merely a programmer simply by accumulating languages — you need to learn how to think about programming problems in a general way, independent of any one language. To be a real hacker, you need to get to the point where you can learn a new language in days by relating what's in the manual to what you already know. This means you should learn several very different languages.<br />
I can't give complete instructions on how to learn to program here — it's a complex skill. But I can tell you that books and courses won't do it — many, maybe <i>most</i> of the best hackers are self-taught. You can learn language features — bits of knowledge — from books, but the mind-set that makes that knowledge into living skill can be learned only by practice and apprenticeship. What will do it is (a) <i>reading code</i> and (b) <i>writing code</i>.<br />
Peter Norvig, who is one of Google's top hackers and the co-author of the most widely used textbook on AI, has written an excellent essay called <a class="ulink" href="http://norvig.com/21-days.html" target="_top">Teach Yourself Programming in Ten Years</a>. His "recipe for programming success" is worth careful attention.<br />
Learning to program is like learning to write good natural language. The best way to do it is to read some stuff written by masters of the form, write some things yourself, read a lot more, write a little more, read a lot more, write some more ... and repeat until your writing begins to develop the kind of strength and economy you see in your models.<br />
Finding good code to read used to be hard, because there were few large programs available in source for fledgeling hackers to read and tinker with. This has changed dramatically; open-source software, programming tools, and operating systems (all built by hackers) are now widely available. Which brings me neatly to our next topic...<br />
</div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title">2. Get one of the open-source Unixes and learn to use and run it.</h3></div></div></div>I'll assume you have a personal computer or can get access to one. (Take a moment to appreciate how much that means. The hacker culture originally evolved back when computers were so expensive that individuals could not own them.) The single most important step any newbie can take toward acquiring hacker skills is to get a copy of Linux or one of the BSD-Unixes or OpenSolaris, install it on a personal machine, and run it.<br />
Yes, there are other operating systems in the world besides Unix. But they're distributed in binary — you can't read the code, and you can't modify it. Trying to learn to hack on a Microsoft Windows machine or under any other closed-source system is like trying to learn to dance while wearing a body cast.<br />
Under Mac OS X it's possible, but only part of the system is open source — you're likely to hit a lot of walls, and you have to be careful not to develop the bad habit of depending on Apple's proprietary code. If you concentrate on the Unix under the hood you can learn some useful things.<br />
Unix is the operating system of the Internet. While you can learn to use the Internet without knowing Unix, you can't be an Internet hacker without understanding Unix. For this reason, the hacker culture today is pretty strongly Unix-centered. (This wasn't always true, and some old-time hackers still aren't happy about it, but the symbiosis between Unix and the Internet has become strong enough that even Microsoft's muscle doesn't seem able to seriously dent it.)<br />
So, bring up a Unix — I like Linux myself but there are other ways (and yes, you <i>can</i> run both Linux and Microsoft Windows on the same machine). Learn it. Run it. Tinker with it. Talk to the Internet with it. Read the code. Modify the code. You'll get better programming tools (including C, LISP, Python, and Perl) than any Microsoft operating system can dream of hosting, you'll have fun, and you'll soak up more knowledge than you realize you're learning until you look back on it as a master hacker.<br />
For more about learning Unix, see <a class="ulink" href="http://catb.org/%7Eesr/faqs/loginataka.html" target="_top">The Loginataka</a>. You might also want to have a look at <a class="ulink" href="http://catb.org/%7Eesr/writings/taoup/" target="_top">The Art Of Unix Programming</a>.<br />
To get your hands on a Linux, see the <a class="ulink" href="http://www.linux.org/" target="_top">Linux Online!</a> site; you can download from there or (better idea) find a local Linux user group to help you with installation.<br />
During the first ten years of this HOWTO's life, I reported that from a new user's point of view, all Linux distributions are almost equivalent. But in 2006-2007, an actual best choice emerged: <a class="ulink" href="http://www.ubuntu.com/" target="_top">Ubuntu</a>. While other distros have their own areas of strength, Ubuntu is far and away the most accessible to Linux newbies.<br />
You can find BSD Unix help and resources at <a class="ulink" href="http://www.bsd.org/" target="_top">www.bsd.org</a>.<br />
A good way to dip your toes in the water is to boot up what Linux fans call a <a class="ulink" href="http://www.livecdnews.com/" target="_top">live CD</a>, a distribution that runs entirely off a CD without having to modify your hard disk. This will be slow, because CDs are slow, but it's a way to get a look at the possibilities without having to do anything drastic.<br />
I have written a primer on the <a class="ulink" href="http://en.tldp.org/HOWTO/Unix-and-Internet-Fundamentals-HOWTO/index.html" target="_top">basics of Unix and the Internet</a>.<br />
I used to recommend against installing either Linux or BSD as a solo project if you're a newbie. Nowadays the installers have gotten good enough that doing it entirely on your own is possible, even for a newbie. Nevertheless, I still recommend making contact with your local Linux user's group and asking for help. It can't hurt, and may smooth the process.<br />
</div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title">3. Learn how to use the World Wide Web and write HTML.</h3></div></div></div>Most of the things the hacker culture has built do their work out of sight, helping run factories and offices and universities without any obvious impact on how non-hackers live. The Web is the one big exception, the huge shiny hacker toy that even <i>politicians</i> admit has changed the world. For this reason alone (and a lot of other good ones as well) you need to learn how to work the Web.<br />
This doesn't just mean learning how to drive a browser (anyone can do that), but learning how to write HTML, the Web's markup language. If you don't know how to program, writing HTML will teach you some mental habits that will help you learn. So build a home page. Try to stick to XHTML, which is a cleaner language than classic HTML. (There are good beginner tutorials on the Web; <a class="ulink" href="http://htmldog.com/" target="_top">here's one</a>.)<br />
But just having a home page isn't anywhere near good enough to make you a hacker. The Web is full of home pages. Most of them are pointless, zero-content sludge — very snazzy-looking sludge, mind you, but sludge all the same (for more on this see <a class="ulink" href="http://catb.org/%7Eesr/html-hell.html" target="_top">The HTML Hell Page</a>).<br />
To be worthwhile, your page must have <i>content</i> — it must be interesting and/or useful to other hackers. And that brings us to the next topic...<br />
</div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title">4. If you don't have functional English, learn it.</h3></div></div></div>As an American and native English-speaker myself, I have previously been reluctant to suggest this, lest it be taken as a sort of cultural imperialism. But several native speakers of other languages have urged me to point out that English is the working language of the hacker culture and the Internet, and that you will need to know it to function in the hacker community.<br />
Back around 1991 I learned that many hackers who have English as a second language use it in technical discussions even when they share a birth tongue; it was reported to me at the time that English has a richer technical vocabulary than any other language and is therefore simply a better tool for the job. For similar reasons, translations of technical books written in English are often unsatisfactory (when they get done at all).<br />
Linus Torvalds, a Finn, comments his code in English (it apparently never occurred to him to do otherwise). His fluency in English has been an important factor in his ability to recruit a worldwide community of developers for Linux. It's an example worth following.<br />
Being a native English-speaker does not guarantee that you have language skills good enough to function as a hacker. If your writing is semi-literate, ungrammatical, and riddled with misspellings, many hackers (including myself) will tend to ignore you. While sloppy writing does not invariably mean sloppy thinking, we've generally found the correlation to be strong — and we have no use for sloppy thinkers. If you can't yet write competently, learn to.<br />
<div class="mediaobject"><img src="http://www.catb.org/%7Eesr/faqs/glider.png" /><br />
</div></div></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both;">Status in the Hacker Culture</h2></div></div></div><div class="toc"><br />
<dl><dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#respect1">1. Write open-source software</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#respect2">2. Help test and debug open-source software</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#respect3">3. Publish useful information</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#respect4">4. Help keep the infrastructure working</a></dt>
<dt><a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#respect5">5. Serve the hacker culture itself</a></dt>
</dl></div>Like most cultures without a money economy, hackerdom runs on reputation. You're trying to solve interesting problems, but how interesting they are, and whether your solutions are really good, is something that only your technical peers or superiors are normally equipped to judge.<br />
Accordingly, when you play the hacker game, you learn to keep score primarily by what other hackers think of your skill (this is why you aren't really a hacker until other hackers consistently call you one). This fact is obscured by the image of hacking as solitary work; also by a hacker-cultural taboo (gradually decaying since the late 1990s but still potent) against admitting that ego or external validation are involved in one's motivation at all.<br />
Specifically, hackerdom is what anthropologists call a <i>gift culture</i>. You gain status and reputation in it not by dominating other people, nor by being beautiful, nor by having things other people want, but rather by giving things away. Specifically, by giving away your time, your creativity, and the results of your skill.<br />
There are basically five kinds of things you can do to be respected by hackers:<br />
<div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title">1. Write open-source software</h3></div></div></div>The first (the most central and most traditional) is to write programs that other hackers think are fun or useful, and give the program sources away to the whole hacker culture to use.<br />
(We used to call these works “free software”, but this confused too many people who weren't sure exactly what “free” was supposed to mean. Most of us now prefer the term “<a class="ulink" href="http://www.opensource.org/" target="_top">open-source</a>” software).<br />
Hackerdom's most revered demigods are people who have written large, capable programs that met a widespread need and given them away, so that now everyone uses them.<br />
But there's a bit of a fine historical point here. While hackers have always looked up to the open-source developers among them as our community's hardest core, before the mid-1990s most hackers most of the time worked on closed source. This was still true when I wrote the first version of this HOWTO in 1996; it took the mainstreaming of open-source software after 1997 to change things. Today, "the hacker community" and "open-source developers" are two descriptions for what is essentially the same culture and population — but it is worth remembering that this was not always so.<br />
</div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title">2. Help test and debug open-source software</h3></div></div></div>They also serve who stand and debug open-source software. In this imperfect world, we will inevitably spend most of our software development time in the debugging phase. That's why any open-source author who's thinking will tell you that good beta-testers (who know how to describe symptoms clearly, localize problems well, can tolerate bugs in a quickie release, and are willing to apply a few simple diagnostic routines) are worth their weight in rubies. Even one of these can make the difference between a debugging phase that's a protracted, exhausting nightmare and one that's merely a salutary nuisance.<br />
If you're a newbie, try to find a program under development that you're interested in and be a good beta-tester. There's a natural progression from helping test programs to helping debug them to helping modify them. You'll learn a lot this way, and generate good karma with people who will help you later on.<br />
</div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title">3. Publish useful information</h3></div></div></div>Another good thing is to collect and filter useful and interesting information into web pages or documents like Frequently Asked Questions (FAQ) lists, and make those generally available.<br />
Maintainers of major technical FAQs get almost as much respect as open-source authors.<br />
</div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title">4. Help keep the infrastructure working</h3></div></div></div>The hacker culture (and the engineering development of the Internet, for that matter) is run by volunteers. There's a lot of necessary but unglamorous work that needs done to keep it going — administering mailing lists, moderating newsgroups, maintaining large software archive sites, developing RFCs and other technical standards.<br />
People who do this sort of thing well get a lot of respect, because everybody knows these jobs are huge time sinks and not as much fun as playing with code. Doing them shows dedication.<br />
</div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title">5. Serve the hacker culture itself</h3></div></div></div>Finally, you can serve and propagate the culture itself (by, for example, writing an accurate primer on how to become a hacker :-)). This is not something you'll be positioned to do until you've been around for while and become well-known for one of the first four things.<br />
The hacker culture doesn't have leaders, exactly, but it does have culture heroes and tribal elders and historians and spokespeople. When you've been in the trenches long enough, you may grow into one of these. Beware: hackers distrust blatant ego in their tribal elders, so visibly reaching for this kind of fame is dangerous. Rather than striving for it, you have to sort of position yourself so it drops in your lap, and then be modest and gracious about your status.<br />
<div class="mediaobject"><img src="http://www.catb.org/%7Eesr/faqs/glider.png" /><br />
</div></div></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both;">The Hacker/Nerd Connection</h2></div></div></div>Contrary to popular myth, you don't have to be a nerd to be a hacker. It does help, however, and many hackers are in fact nerds. Being something of a social outcast helps you stay concentrated on the really important things, like thinking and hacking.<br />
For this reason, many hackers have adopted the label ‘geek’ as a badge of pride — it's a way of declaring their independence from normal social expectations (as well as a fondness for other things like science fiction and strategy games that often go with being a hacker). The term 'nerd' used to be used this way back in the 1990s, back when 'nerd' was a mild pejorative and 'geek' a rather harsher one; sometime after 2000 they switched places, at least in U.S. popular culture, and there is now even a significant geek-pride culture among people who aren't techies.<br />
If you can manage to concentrate enough on hacking to be good at it and still have a life, that's fine. This is a lot easier today than it was when I was a newbie in the 1970s; mainstream culture is much friendlier to techno-nerds now. There are even growing numbers of people who realize that hackers are often high-quality lover and spouse material.<br />
If you're attracted to hacking because you don't have a life, that's OK too — at least you won't have trouble concentrating. Maybe you'll get a life later on.<br />
<div class="mediaobject"><img src="http://www.catb.org/%7Eesr/faqs/glider.png" /><br />
</div></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both;">Points For Style</h2></div></div></div>Again, to be a hacker, you have to enter the hacker mindset. There are some things you can do when you're not at a computer that seem to help. They're not substitutes for hacking (nothing is) but many hackers do them, and feel that they connect in some basic way with the essence of hacking.<br />
<div class="itemizedlist"><ul type="disc"><li>Learn to write your native language well. Though it's a common stereotype that programmers can't write, a surprising number of hackers (including all the most accomplished ones I know of) are very able writers.<br />
</li>
<li>Read science fiction. Go to science fiction conventions (a good way to meet hackers and proto-hackers). <br />
</li>
<li>Train in a martial-arts form. The kind of mental discipline required for martial arts seems to be similar in important ways to what hackers do. The most popular forms among hackers are definitely Asian empty-hand arts such as Tae Kwon Do, various forms of Karate, Kung Fu, Aikido, or Ju Jitsu. Western fencing and Asian sword arts also have visible followings. In places where it's legal, pistol shooting has been rising in popularity since the late 1990s. The most hackerly martial arts are those which emphasize mental discipline, relaxed awareness, and control, rather than raw strength, athleticism, or physical toughness.<br />
</li>
<li>Study an actual meditation discipline. The perennial favorite among hackers is Zen (importantly, it is possible to benefit from Zen without acquiring a religion or discarding one you already have). Other styles may work as well, but be careful to choose one that doesn't require you to believe crazy things.<br />
</li>
<li> Develop an analytical ear for music. Learn to appreciate peculiar kinds of music. Learn to play some musical instrument well, or how to sing.<br />
</li>
<li> Develop your appreciation of puns and wordplay.<br />
</li>
</ul></div>The more of these things you already do, the more likely it is that you are natural hacker material. Why these things in particular is not completely clear, but they're connected with a mix of left- and right-brain skills that seems to be important; hackers need to be able to both reason logically and step outside the apparent logic of a problem at a moment's notice.<br />
Work as intensely as you play and play as intensely as you work. For true hackers, the boundaries between "play", "work", "science" and "art" all tend to disappear, or to merge into a high-level creative playfulness. Also, don't be content with a narrow range of skills. Though most hackers self-describe as programmers, they are very likely to be more than competent in several related skills — system administration, web design, and PC hardware troubleshooting are common ones. A hacker who's a system administrator, on the other hand, is likely to be quite skilled at script programming and web design. Hackers don't do things by halves; if they invest in a skill at all, they tend to get very good at it.<br />
Finally, a few things <i>not</i> to do.<br />
<div class="itemizedlist"><ul type="disc"><li> Don't use a silly, grandiose user ID or screen name. <br />
</li>
<li> Don't get in flame wars on Usenet (or anywhere else).<br />
</li>
<li> Don't call yourself a ‘cyberpunk’, and don't waste your time on anybody who does.<br />
</li>
<li> Don't post or email writing that's full of spelling errors and bad grammar.<br />
</li>
</ul></div>The only reputation you'll make doing any of these things is as a twit. Hackers have long memories — it could take you years to live your early blunders down enough to be accepted.<br />
The problem with screen names or handles deserves some amplification. Concealing your identity behind a handle is a juvenile and silly behavior characteristic of crackers, warez d00dz, and other lower life forms. Hackers don't do this; they're proud of what they do and want it associated with their <i>real</i> names. So if you have a handle, drop it. In the hacker culture it will only mark you as a loser.<br />
<div class="mediaobject"><img src="http://www.catb.org/%7Eesr/faqs/glider.png" /><br />
</div></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both;">Other Resources</h2></div></div></div>Paul Graham has written an essay called <a class="ulink" href="http://www.paulgraham.com/gh.html" target="_top">Great Hackers</a>, and another on <a class="ulink" href="http://www.paulgraham.com/college.html" target="_top">Undergraduation</a>, in which he speaks much wisdom.<br />
There is a document called <a class="ulink" href="http://samizdat.mines.edu/howto/HowToBeAProgrammer.html" target="_top">How To Be A Programmer</a> that is an excellent complement to this one. It has valuable advice not just about coding and skillsets, but about how to function on a programming team.<br />
I have also written <a class="ulink" href="http://catb.org/%7Eesr/writings/hacker-history/hacker-history.html" target="_top"><i class="citetitle">A Brief History Of Hackerdom</i></a>.<br />
I have written a paper, <a class="ulink" href="http://catb.org/%7Eesr/writings/cathedral-bazaar/index.html" target="_top"><i class="citetitle">The Cathedral and the Bazaar</i></a>, which explains a lot about how the Linux and open-source cultures work. I have addressed this topic even more directly in its sequel <a class="ulink" href="http://catb.org/%7Eesr/writings/homesteading/" target="_top"><i class="citetitle">Homesteading the Noosphere</i></a>.<br />
Rick Moen has written an excellent document on <a class="ulink" href="http://linuxmafia.com/faq/Linux_PR/newlug.html" target="_top">how to run a Linux user group</a>.<br />
Rick Moen and I have collaborated on another document on <a class="ulink" href="http://catb.org/%7Eesr/faqs/smart-questions.html" target="_top">How To Ask Smart Questions</a>. This will help you seek assistance in a way that makes it more likely that you will actually get it.<br />
If you need instruction in the basics of how personal computers, Unix, and the Internet work, see <a class="ulink" href="http://en.tldp.org/HOWTO//Unix-and-Internet-Fundamentals-HOWTO/" target="_top"> The Unix and Internet Fundamentals HOWTO</a>. <br />
When you release software or write patches for software, try to follow the guidelines in the <a class="ulink" href="http://en.tldp.org/HOWTO/Software-Release-Practice-HOWTO/index.html" target="_top"> Software Release Practice HOWTO</a>.<br />
If you enjoyed the Zen poem, you might also like <a class="ulink" href="http://catb.org/%7Eesr//writings/unix-koans" target="_top">Rootless Root: The Unix Koans of Master Foo</a>.<br />
<div class="mediaobject"><img src="http://www.catb.org/%7Eesr/faqs/glider.png" /><br />
</div></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both;">Frequently Asked Questions</h2></div></div></div><div class="qandaset"><br />
<dl><dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#hacker_already">How do I tell if I am already a hacker?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#teach_hack">Will you teach me how to hack?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#getting_started">How can I get started, then?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#when_start">When do you have to start? Is it too late for me to learn?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#how_long">How long will it take me to learn to hack?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#closed_lang">Is Visual Basic a good language to start with?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#I_want_to_crack_and_Im_an_idiot">Would you help me to crack a system, or teach me how to crack?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#passwords">How can I get the password for someone else's account?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#crackmail">How can I break into/read/monitor someone else's email?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#crackop">How can I steal channel op privileges on IRC?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#anti_crack">I've been cracked. Will you help me fend off further attacks?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#windows_grief">I'm having problems with my Windows software. Will you help me?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#real_hackers">Where can I find some real hackers to talk with?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#books">Can you recommend useful books about hacking-related subjects?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#mathematics">Do I need to be good at math to become a hacker?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#language_first">What language should I learn first?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#hardware">What kind of hardware do I need?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#started2">I want to contribute. Can you help me pick a problem to work on?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#MS_hater">Do I need to hate and bash Microsoft?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#no_living">But won't open-source software leave programmers unable to make a living?</a></dt>
<dt>Q: <a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#problems">Where can I get a free Unix?</a></dt>
</dl><table border="0" summary="Q and A Set"><col align="left" width="1%"></col><tbody>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">How do I tell if I am already a hacker?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">Ask yourself the following three questions:<br />
<div class="itemizedlist"><ul type="disc"><li>Do you speak code, fluently?<br />
</li>
<li>Do you identify with the goals and values of the hacker community?<br />
</li>
<li>Has a well-established member of the hacker community ever called you a hacker?<br />
</li>
</ul></div>If you can answer yes to <i>all three</i> of these questions, you are already a hacker. No two alone are sufficient.<br />
The first test is about skills. You probably pass it if you have the minimum technical skills described earlier in this document. You blow right through it if you have had a substantial amount of code accepted by an open-source development project.<br />
The second test is about attitude. If the <a class="link" href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#attitude" title="The Hacker Attitude">five principles of the hacker mindset</a> seemed obvious to you, more like a description of the way you already live than anything novel, you are already halfway to passing it. That's the inward half; the other, outward half is the degree to which you identify with the hacker community's long-term projects.<br />
Here is an incomplete but indicative list of some of those projects: Does it matter to you that Linux improve and spread? Are you passionate about software freedom? Hostile to monopolies? Do you act on the belief that computers can be instruments of empowerment that make the world a richer and more humane place?<br />
But a note of caution is in order here. The hacker community has some specific, primarily defensive political interests — two of them are defending free-speech rights and fending off "intellectual-property" power grabs that would make open source illegal. Some of those long-term projects are civil-liberties organizations like the Electronic Frontier Foundation, and the outward attitude properly includes support of them. But beyond that, most hackers view attempts to systematize the hacker attitude into an explicit political program with suspicion; we've learned, the hard way, that these attempts are divisive and distracting. If someone tries to recruit you to march on your capitol in the name of the hacker attitude, they've missed the point. The right response is probably “Shut up and show them the code.”<br />
The third test has a tricky element of recursiveness about it. I observed in <a class="xref" href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#what_is" title="What Is a Hacker?">the section called “What Is a Hacker?”</a> that being a hacker is partly a matter of belonging to a particular subculture or social network with a shared history, an inside and an outside. In the far past, hackers were a much less cohesive and self-aware group than they are today. But the importance of the social-network aspect has increased over the last thirty years as the Internet has made connections with the core of the hacker subculture easier to develop and maintain. One easy behavioral index of the change is that, in this century, we have our own T-shirts.<br />
Sociologists, who study networks like those of the hacker culture under the general rubric of "invisible colleges", have noted that one characteristic of such networks is that they have gatekeepers — core members with the social authority to endorse new members into the network. Because the "invisible college" that is hacker culture is a loose and informal one, the role of gatekeeper is informal too. But one thing that all hackers understand in their bones is that not every hacker is a gatekeeper. Gatekeepers have to have a certain degree of seniority and accomplishment before they can bestow the title. How much is hard to quantify, but every hacker knows it when they see it.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">Will you teach me how to hack?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">Since first publishing this page, I've gotten several requests a week (often several a day) from people to "teach me all about hacking". Unfortunately, I don't have the time or energy to do this; my own hacking projects, and working as an open-source advocate, take up 110% of my time.<br />
Even if I did, hacking is an attitude and skill you basically have to teach yourself. You'll find that while real hackers want to help you, they won't respect you if you beg to be spoon-fed everything they know.<br />
Learn a few things first. Show that you're trying, that you're capable of learning on your own. Then go to the hackers you meet with specific questions.<br />
If you do email a hacker asking for advice, here are two things to know up front. First, we've found that people who are lazy or careless in their writing are usually too lazy and careless in their thinking to make good hackers — so take care to spell correctly, and use good grammar and punctuation, otherwise you'll probably be ignored. Secondly, don't <i>dare</i> ask for a reply to an ISP account that's different from the account you're sending from; we find people who do that are usually thieves using stolen accounts, and we have no interest in rewarding or assisting thievery.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">How can I get started, then?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">The best way for you to get started would probably be to go to a LUG (Linux user group) meeting. You can find such groups on the <a class="ulink" href="http://www.tldp.org/links/index.html" target="_top">LDP General Linux Information Page</a>; there is probably one near you, possibly associated with a college or university. LUG members will probably give you a Linux if you ask, and will certainly help you install one and get started.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">When do you have to start? Is it too late for me to learn?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">Any age at which you are motivated to start is a good age. Most people seem to get interested between ages 15 and 20, but I know of exceptions in both directions.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">How long will it take me to learn to hack?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">That depends on how talented you are and how hard you work at it. Most people who try can acquire a respectable skill set in eighteen months to two years, if they concentrate. Don't think it ends there, though; in hacking (as in many other fields) it takes about ten years to achieve mastery. And if you are a real hacker, you will spend the rest of your life learning and perfecting your craft.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">Is Visual Basic a good language to start with?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">If you're asking this question, it almost certainly means you're thinking about trying to hack under Microsoft Windows. This is a bad idea in itself. When I compared trying to learn to hack under Windows to trying to learn to dance while wearing a body cast, I wasn't kidding. Don't go there. It's ugly, and it never stops being ugly.<br />
There is a specific problem with Visual Basic; mainly that it's not portable. Though there is a prototype open-source implementations of Visual Basic, the applicable ECMA standards don't cover more than a small set of its programming interfaces. On Windows most of its library support is proprietary to a single vendor (Microsoft); if you aren't <i>extremely</i> careful about which features you use — more careful than any newbie is really capable of being — you'll end up locked into only those platforms Microsoft chooses to support. If you're starting on a Unix, much better languages with better libraries are available. Python, for example.<br />
Also, like other Basics, Visual Basic is a poorly-designed language that will teach you bad programming habits. No, <i>don't</i> ask me to describe them in detail; that explanation would fill a book. Learn a well-designed language instead.<br />
One of those bad habits is becoming dependent on a single vendor's libraries, widgets, and development tools. In general, any language that isn't fully supported under at least Linux or one of the BSDs, and/or at least three different vendors' operating systems, is a poor one to learn to hack in.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">Would you help me to crack a system, or teach me how to crack?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">No. Anyone who can still ask such a question after reading this FAQ is too stupid to be educable even if I had the time for tutoring. Any emailed requests of this kind that I get will be ignored or answered with extreme rudeness.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">How can I get the password for someone else's account?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">This is cracking. Go away, idiot.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">How can I break into/read/monitor someone else's email?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">This is cracking. Get lost, moron.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">How can I steal channel op privileges on IRC?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">This is cracking. Begone, cretin.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">I've been cracked. Will you help me fend off further attacks?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">No. Every time I've been asked this question so far, it's been from some poor sap running Microsoft Windows. It is not possible to effectively secure Windows systems against crack attacks; the code and architecture simply have too many flaws, which makes securing Windows like trying to bail out a boat with a sieve. The only reliable prevention starts with switching to Linux or some other operating system that is designed to at least be capable of security.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">I'm having problems with my Windows software. Will you help me?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">Yes. Go to a DOS prompt and type "format c:". Any problems you are experiencing will cease within a few minutes.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">Where can I find some real hackers to talk with?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">The best way is to find a Unix or Linux user's group local to you and go to their meetings (you can find links to several lists of user groups on the <a class="ulink" href="http://www.tldp.org/" target="_top">LDP</a> site at ibiblio).<br />
(I used to say here that you wouldn't find any real hackers on IRC, but I'm given to understand this is changing. Apparently some real hacker communities, attached to things like GIMP and Perl, have IRC channels now.)<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">Can you recommend useful books about hacking-related subjects?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">I maintain a <a class="ulink" href="http://en.tldp.org/HOWTO/Reading-List-HOWTO/index.html" target="_top"> Linux Reading List HOWTO</a> that you may find helpful. The <a class="ulink" href="http://www.catb.org/%7Eesr/faqs/loginataka.html" target="_top">Loginataka</a> may also be interesting.<br />
For an introduction to Python, see the <a class="ulink" href="http://www.python.org/doc/Intros.html" target="_top">introductory materials</a> on the Python site.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">Do I need to be good at math to become a hacker?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">No. Hacking uses very little formal mathematics or arithmetic. In particular, you won't usually need trigonometry, calculus or analysis (there are exceptions to this in a handful of specific application areas like 3-D computer graphics). Knowing some formal logic and Boolean algebra is good. Some grounding in finite mathematics (including finite-set theory, combinatorics, and graph theory) can be helpful.<br />
Much more importantly: you need to be able to think logically and follow chains of exact reasoning, the way mathematicians do. While the content of most mathematics won't help you, you will need the discipline and intelligence to handle mathematics. If you lack the intelligence, there is little hope for you as a hacker; if you lack the discipline, you'd better grow it.<br />
I think a good way to find out if you have what it takes is to pick up a copy of Raymond Smullyan's book <i class="citetitle">What Is The Name Of This Book?</i>. Smullyan's playful logical conundrums are very much in the hacker spirit. Being able to solve them is a good sign; <i>enjoying</i> solving them is an even better one.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">What language should I learn first?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">XHTML (the latest dialect of HTML) if you don't already know it. There are a lot of glossy, hype-intensive <i>bad</i> HTML books out there, and distressingly few good ones. The one I like best is <a class="ulink" href="http://www.oreilly.com/catalog/html5/" target="_top"><i class="citetitle">HTML: The Definitive Guide</i></a>.<br />
But HTML is not a full programming language. When you're ready to start programming, I would recommend starting with <a class="ulink" href="http://www.python.org/" target="_top">Python</a>. You will hear a lot of people recommending Perl, and Perl is still more popular than Python, but it's harder to learn and (in my opinion) less well designed.<br />
C is really important, but it's also much more difficult than either Python or Perl. Don't try to learn it first.<br />
Windows users, do <i>not</i> settle for Visual Basic. It will teach you bad habits, and it's not portable off Windows. Avoid.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">What kind of hardware do I need?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">It used to be that personal computers were rather underpowered and memory-poor, enough so that they placed artificial limits on a hacker's learning process. This stopped being true in the mid-1990s; any machine from an Intel 486DX50 up is more than powerful enough for development work, X, and Internet communications, and the smallest disks you can buy today are plenty big enough.<br />
The important thing in choosing a machine on which to learn is whether its hardware is Linux-compatible (or BSD-compatible, should you choose to go that route). Again, this will be true for almost all modern machines. The only really sticky areas are modems and wireless cards; some machines have Windows-specific hardware that won't work with Linux.<br />
There's a FAQ on hardware compatibility; the latest version is <a class="ulink" href="http://en.tldp.org/HOWTO/Hardware-HOWTO/index.html" target="_top"> here</a>.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">I want to contribute. Can you help me pick a problem to work on?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">No, because I don't know your talents or interests. You have to be self-motivated or you won't stick, which is why having other people choose your direction almost never works.<br />
Try this. Watch the project announcements scroll by on <a class="ulink" href="http://freshmeat.net/" target="_top">Freshmeat</a> for a few days. When you see one that makes you think "Cool! I'd like to work on that!", join it.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">Do I need to hate and bash Microsoft?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">No, you don't. Not that Microsoft isn't loathsome, but there was a hacker culture long before Microsoft and there will still be one long after Microsoft is history. Any energy you spend hating Microsoft would be better spent on loving your craft. Write good code — that will bash Microsoft quite sufficiently without polluting your karma.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">But won't open-source software leave programmers unable to make a living?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">This seems unlikely — so far, the open-source software industry seems to be creating jobs rather than taking them away. If having a program written is a net economic gain over not having it written, a programmer will get paid whether or not the program is going to be open-source after it's done. And, no matter how much "free" software gets written, there always seems to be more demand for new and customized applications. I've written more about this at the <a class="ulink" href="http://www.opensource.org/" target="_top">Open Source</a> pages.<br />
</td></tr>
<tr class="question"><td align="left" valign="top"><b>Q:</b><br />
</td><td align="left" valign="top">Where can I get a free Unix?<br />
</td></tr>
<tr class="answer"><td align="left" valign="top"><b>A:</b><br />
</td><td align="left" valign="top">If you don't have a Unix installed on your machine yet, elsewhere on this page I include pointers to where to get the most commonly used free Unix. To be a hacker you need motivation and initiative and the ability to educate yourself. Start now...<br />
</td></tr>
</tbody></table></div><div class="mediaobject"><img src="http://www.catb.org/%7Eesr/faqs/glider.png" /><br />
</div></div>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com0tag:blogger.com,1999:blog-4276715425787171951.post-60576862923257834612009-09-23T15:45:00.000+05:302009-09-23T15:45:45.976+05:30Installing Code::Blocks c/c++ IDE on Ubuntu 9.04Visit first the Code:.Blocks' website: <a href="http://www.codeblocks.org/">http://www.codeblocks.org</a> and define <a href="http://en.wikipedia.org/wiki/Codeblocks">Code::Blocks...</a><br />
<br />
<br />
<table border="0" cellpadding="2" cellspacing="1" style="height: 103px; text-align: left; width: 260px;"><tbody>
<tr> <td style="vertical-align: top;"><a href="http://www.futuredesktop.org/jaunty/images/codeblocks1.png"><img alt="Picture-1" src="http://www.futuredesktop.org/jaunty/images/codeblocks1-t.png" style="border: 0px solid; height: 134px; width: 216px;" /></a></td> </tr>
</tbody> </table><h3><span style="font-weight: bold;">Installation on Ubuntu 9.04 <br />
</span></h3><h3><span style="font-weight: bold;"></span></h3>Update package index first<br />
$ <span style="color: #006600;">sudo aptitude update<br />
<br />
</span>Install required packages<span style="color: #006600;"><br />
</span><span style="color: #006600;"></span>$ <span style="color: #006600;">sudo aptitude install codeblocks </span><span style="color: #006600;">codeblocks-contrib</span><br />
<br />
For code development, you'll also need some additional packages. Run<br />
$ <span style="color: #006600;">sudo </span><span style="color: #006600;">aptitude</span><span style="color: #006600;"> install build-essential gdb subversion</span><br />
<br />
$ <span style="color: #006600;">sudo </span><span style="color: #006600;"></span><span style="color: #006600;">aptitude</span><span style="color: #006600;"> </span><span style="color: #006600;">install automake autoconf libtool</span><br />
<br />
$ <span style="color: #006600;">sudo </span><span style="color: #006600;"></span><span style="color: #006600;">aptitude</span><span style="color: #006600;"> </span><span style="color: #006600;">install libgtk2.0-dev libxmu-dev libxxf86vm-dev</span><br />
<br />
These package are for programming with the wxWidgets GUI toolkit. Code::blocks itself is a pure wxWidgets product.<br />
$ <span style="color: #006600;">sudo </span><span style="color: #006600;"></span><span style="color: #006600;">aptitude</span><span style="color: #006600;"> </span><span style="color: #006600;">install libwxbase2.8-dev wx2.8-headers libwxgtk2.8-dev wx-common</span><br />
------------------------------<br />
<br />
Then start the codeblocks IDE from the Application -> Programming menu or type:<br />
$ <span style="color: #006600;">codeblocks</span><br />
<br />
The first launch will ask the compiler name. The default c/c++ compiler in Linux is "GNU GCC compiler". <br />
Select it. See picture:<br />
<a href="http://www.futuredesktop.org/jaunty/images/codeblocks2.png"><img alt="Select compiler" src="http://www.futuredesktop.org/jaunty/images/codeblocks2-t.png" style="border: 0px solid; height: 93px; width: 150px;" /></a><br />
------------------------------<br />
Below are some important notes. Especially read the notes 1- 5.<br />
Use the (glut) freeglut library to develope portable OpenGL applications. Read note 1.<br />
Code::Blocks has a GLUT project wizard. Use it to create your first OpenGL project. Build & run.<br />
<hr style="height: 2px; width: 100%;" /> <h3>Some important notes.</h3>Alguns comentários importantes.<br />
<br />
<span style="color: #cc0000; font-weight: bold;">[ Note 1 ]</span><br />
If you want to develope OpenGL (<a href="http://freeglut.sourceforge.net/">glut...</a>) applications, install FreeGlut first :-)<br />
<br />
Click <a href="apt://freeglut3,freeglut3-dev">this link...</a> or type the command manually.<span style="color: #006600;"><br />
<br />
</span>$ <span style="color: #006600;">sudo aptitude install freeglut3 freeglut3-dev </span><br />
<br />
Ceate a new project and select the "GLUT project" in the project wizard.<br />
An important tip: Say: <span style="color: #3333ff; font-weight: bold;">/usr</span> when it asks the "Please, Select GLUT's location:".<br />
See picture <a href="http://www.futuredesktop.org/jaunty/images/codeblocks3.png"><img alt="GLUT's location" src="http://www.futuredesktop.org/jaunty/images/codeblocks3-t.png" style="border: 0px solid; height: 93px; width: 150px;" /></a><br />
Read also the Note 5) below.<br />
<hr style="height: 2px; width: 100%;" /><br />
<span style="color: #cc0000; font-weight: bold;">[ Note 2 ]</span><br />
<span style="text-decoration: line-through;"> If you want to develope GLFW applications, install GLFW first ( </span><a href="http://glfw.sourceforge.net/" style="text-decoration: line-through;">http://glfw.sourceforge.net/</a><span style="text-decoration: line-through;"> ) </span><br />
<span style="text-decoration: line-through;"> Read also this </span><a href="http://ubuntuforums.org/showthread.php?p=3630703#post3630703" style="text-decoration: line-through;">posting...</a><span style="text-decoration: line-through;"> </span><br />
The Ubuntu's freeglut library is more up-to-date than GLFW.<br />
<hr style="height: 2px; width: 100%;" /><br />
<span style="color: #cc0000; font-weight: bold;">[ Note 3 ]</span>, c-cpp-reference:<br />
Do not forget to install the "c-cpp-reference" manuals. Run this command:<br />
$<span style="color: #006600;"> sudo aptitude install c-cpp-reference</span><br />
<br />
OR use your Synaptic Package Manager and get the package. It will put some help files in the /usr/share/doc/c-cpp-reference/ directory. <br />
Start Firefox and point it to <span style="font-weight: bold;">/usr/share/doc/c-cpp-reference/index.html</span><br />
<br />
Also these C/C++ sites are very helpful:<br />
<a href="http://www.cppreference.com/">http://www.cppreference.com</a><br />
+<br />
<a href="http://www.cplusplus.com/">http://www.cplusplus.com</a><br />
+<br />
<a href="http://www.yolinux.com/TUTORIALS/LinuxTutorialC++.html">LinuxTutorialC++.html</a> + <a href="http://www.techbooksforfree.com/ccpp.shtml">Informit.com's book..</a><span style="text-decoration: underline;"><br />
<br />
</span>+ The ultimate collection of C++ tutorials<br />
<a href="http://ubuntuforums.org/showthread.php?t=333867#2">http://ubuntuforums.org/showthread.php?t=333867#2</a> and <a href="http://en.wikibooks.org/wiki/C%2B%2B">C++ wikibook...</a><br />
<br />
+ STL (Standard Template Library) guide<br />
<a href="http://www.yolinux.com/TUTORIALS/LinuxTutorialC++STL.html">http://www.yolinux.com/TUTORIALS/LinuxTutorialC++STL.html</a> (couple of simple STL samples <a href="http://www.futuredesktop.org/tmp/test-std1.cpp">test-std1.cpp</a> and <a href="http://www.futuredesktop.org/tmp/test-std2.cpp">test-std2.cpp</a> ) <br />
<hr style="height: 2px; width: 100%;" /><br />
<span style="color: #cc0000; font-weight: bold;">[ Note 4 ]</span>, <nothing far="" so=""><br />
<br />
<hr style="height: 2px; width: 100%;" /><br />
<span style="color: #cc0000; font-weight: bold;">[ Note 5 ]</span>, Important GLUT / OpenGL guides: <br />
Define <a href="http://en.wikipedia.org/wiki/OpenGL" style="background-color: #cccccc;">OpenGL...</a> <a href="http://www.opengl.org/" style="background-color: #cccccc;">Homepage...</a><br />
<br />
Read the <span style="font-weight: bold;">note 1)</span> first, then study<br />
<br />
<a href="http://www.polytech.unice.fr/%7Ebuffa/cours/synthese_image/DOCS/trant.sgi.com/opengl/examples/redbook/redbook.html" style="background-color: #ffcccc;">Redbook.html</a> <a href="http://www.opengl.org/documentation/red_book/" style="background-color: #ffcccc;">Redbook....</a> ( <a href="http://www.glprogramming.com/red">direct link...</a> )<br />
<br />
<a href="http://www.gamedev.net/reference/count.asp?LinkID=611" style="background-color: #ccffff;">Bluebook.html</a> ( <a href="http://www.glprogramming.com/blue">direct link...</a> )<br />
<br />
<a href="http://www.opengl.org/code/category/C19/">http://www.opengl.org/code/category/C19/</a><br />
<a href="http://nehe.gamedev.net/">http://nehe.gamedev.net</a> ( example: how to run the <a href="http://ubuntuforums.org/showthread.php?p=2868563#post2868563">lessons...</a> on Linux ! ) <br />
<a href="http://ubuntuforums.org/showthread.php?t=333867#8">http://ubuntuforums.org/showthread.php?t=333867#8</a> Especially good source of programming guides !<br />
<a href="http://www.gamedev.net/">http://www.gamedev.net</a> <br />
<a href="http://www.glprogramming.com/">http://www.glprogramming.com</a><br />
<a href="http://ubuntu-gamedev.wikispaces.com/">http://ubuntu-gamedev.wikispaces.com</a> ( Ubuntu games )<br />
<a href="http://www.glchronicles.mccolm.org/">http://www.glchronicles.mccolm.org</a> (GL Chronicles)<br />
<br />
<a href="http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-837Fall2003/CourseHome/index.htm">MIT computer graphics (pdf)...</a><br />
<br />
<a href="http://www.libsdl.org/">http://www.libsdl.org</a> Simple Direct Media Layer (Excellent 2D library. Has also OpenGL support )<br />
<a href="http://lazyfoo.net/SDL_tutorials/index.php">http://lazyfoo.net/SDL_tutorials/index.php</a> (<a href="http://student.kuleuven.be/%7Em0216922/CG/">....</a>) <br />
or try<br />
<a href="http://g2.sourceforge.net/">http://g2.sourceforge.net/</a><br />
---<br />
GLUI = OpenGL based GUI library (buttons, edit boxes, list boxes etc...)<br />
<a href="http://glui.sourceforge.net/">http://glui.sourceforge.net</a><br />
<br />
FTGL = Render text (fonts) in OpenGL<br />
<a href="http://homepages.paradise.net.nz/henryj/code/#FTGL">http://homepages.paradise.net.nz/henryj/code/#FTGL</a><br />
<br />
Animated OpenGL graphical UI, also to be used in GNOME 3.0 and GTK 3 !<br />
<a href="http://clutter-project.org/">http://clutter-project.org</a><br />
<br />
OpenAL sound<br />
<a href="http://www.openal.org/">http://www.openal.org</a><br />
<br />
Ubuntu gamers' corner<br />
<a href="http://ubuntu-gamedev.wikispaces.com/">http://ubuntu-gamedev.wikispaces.com/</a><br />
<hr style="height: 2px; width: 100%;" /><br />
<span style="color: #cc0000; font-weight: bold;">[ Note 6 ]</span>, wxWidgets examples ! <br />
Define <a href="http://en.wikipedia.org/wiki/Wxwidgets" style="background-color: #cccccc;">wxWidgets...</a> <a href="http://wxwidgets.org/" style="background-color: #cccccc;">Homepage...</a><br />
<br />
WxWidgets is a multi platform GUI toolkit.<span style="text-decoration: underline;"><br />
</span><br />
First, install the wx2.8-examples package<br />
$ <span style="color: #009900;">sudo aptitude install wx2.8-examples</span><br />
<br />
The package puts the examples into <span style="font-weight: bold;">/usr/share/doc/wx2.8-examples/examples/</span> directory. It's a compressed tar-ball which you have to unpack/untar.<br />
<br />
Run the "unpack_examples.sh" script (in the same directory) to unpack the samples to your $HOME directory. <br />
For example, run:<br />
$ <span style="color: #009900;">/usr/share/doc/wx2.8-examples/examples/unpack_examples.sh $HOME/wxwidgets2.8</span><br />
<br />
And it will unpack & put the samples into your <span style="font-weight: bold;">$HOME/wxwidgets2.8/samples/</span> folder.<br />
<br />
You can now compile and run the examples directly from the command line. <br />
The compilaton requires wxWidgets' development headers and libraries. <span style="font-weight: bold;">You will need these packages;</span> libwxbase2.8-dev wx2.8-headers libwxgtk2.8-dev<br />
<br />
As an example let's compile the /popup sample code. First, move to the samples/popup/ directory<br />
$ <span style="color: #009900;">cd $HOME/wxwidgets2.8/samples/popup/</span><br />
<br />
Compile the project. <br />
$ <span style="color: #009900;">make</span> <br />
<br />
Run it <br />
$ <span style="color: #009900;">./popup </span><br />
<span style="color: #ff6600; font-weight: bold;">./</span> means the current directory. Yu must include it, otherwise the shell will not find the program, because by default, the current directory is NOT in the $PATH. <br />
$ echo $PATH<br />
<br />
<span style="font-weight: bold;">Now, try to compile and run the other wxWidgets examples as well.</span><br />
<br />
Study also the wxWidgets' documentation package wx2.8-doc.<br />
$ <span style="color: #009900;">aptitude search wx2.8-doc<br />
</span>wx2.8-doc - wxWidgets Cross-platform C++ GUI toolkit (documentation)<br />
<br />
<span style="text-decoration: underline;">Install it</span> and list the documentation (html) files<br />
$ <span style="color: #009900;">dpkg -L wx2.8-doc</span><br />
$ <span style="color: #009900;">dpkg -L wx2.8-doc | grep index<br />
</span>And then open the <span style="font-weight: bold;">index.html</span> in Firefox.<span style="color: #009900;"><br />
</span><br />
Of course, the <a href="http://www.wxwidgets.org/docs/">documentation is available online too...</a><br />
+ <br />
read <a href="http://zetcode.com/tutorials/wxwidgetstutorial/">http://zetcode.com/tutorials/wxwidgetstutorial</a> and <a href="http://en.wikibooks.org/wiki/WxWidgets">http://en.wikibooks.org/wiki/...</a><br />
<hr style="height: 2px; width: 100%;" /><br />
<span style="color: #cc0000; font-weight: bold;">[ Note 7 ]</span>, Necessary packages to develope SDL-applications.<br />
Define <a href="http://en.wikipedia.org/wiki/Simple_DirectMedia_Layer" style="background-color: #cccccc;">SDL...</a> <a href="http://www.libsdl.org/" style="background-color: #cccccc;">Homepage...</a><br />
<br />
SDL stands for <a href="http://en.wikipedia.org/wiki/Simple_DirectMedia_Layer">Simple DirectMedia Layer...</a><br />
It's a framework to greate portable 2D graphics applications. It also supports OpenGL.<br />
<br />
First, list all packages that belong to the SDL family.<br />
$ <span style="color: #009900;">aptitude search libsdl | grep dev</span><br />
The "-dev" packages contain the header (include) files and dynamic libraries for app development. You'll need them.<br />
<br />
Install at least these basic packages. These give you a good start.<br />
$ <span style="color: #009900;">sudo aptitude install libsdl1.2-dev libsdl-image1.2-dev libsdl-sound1.2-dev libsdl-mixer1.2-dev </span><br />
However, the most basic apps need only the "libsdl1.2-dev".<br />
<br />
Then create a basic SDL-application via the Code::Blocks' project wizard (select SDL project).<br />
<a href="http://bildr.no/view/139790"><img alt="SDL applications" src="http://bildr.no/thumb/139790.jpeg" style="border: 0px solid; height: 93px; width: 150px;" /></a><br />
<br />
Note: The SDL's <span style="font-weight: bold;">sound</span>, <span style="font-weight: bold;">image</span> and <span style="font-weight: bold;">mixer</span> functions have their own libraries and include files which you must add to your project.<br />
<a href="http://bildr.no/view/199632"><img alt="SDL applications" src="http://bildr.no/thumb/199632.jpeg" style="border: 0px solid; height: 93px; width: 150px;" /></a><br />
And add these includes to your code:<br />
<span style="font-family: Courier New,Courier,monospace;">#include <sdl_image.h><br />
#include <sdl_mixer.h><br />
#include <sdl_sound.h><br />
</sdl_sound.h></sdl_mixer.h></sdl_image.h></span><span style="color: #009900;"><br />
</span>Additional information:<br />
<span style="color: #009900;"></span>This command will list the installed SDL related packages<br />
$ <span style="color: #009900;">dpkg -l | grep libsdl</span><br />
<br />
<span style="color: #009900;"></span>This command will list the installed SDL related libraries<span style="color: #009900;"><br />
</span><span style="color: #009900;"></span>$ <span style="color: #009900;">ls -l /usr/lib/libSDL*so</span><br />
<br />
This command will list the available include files (most of them are included through the SDL.h)<br />
$ <span style="color: #009900;">ls -l /usr/include/SDL/*</span><br />
<span style="color: #009900;"><br />
</span>This command (already in your project's build options) finds the library PATH, library name and the include PATH + possible debug options.<br />
All well done libraries have this xxx-config thing.<br />
<span style="color: #009900;"></span>$<span style="color: #009900;"> sdl-config --cflags --libs<br />
<br />
</span>See also <a href="http://lazyfoo.net/SDL_tutorials/index.php">SDL_tutorials...</a>, <a href="http://wiki.gamedev.net/index.php/SDL">gamedev.net/SDL</a> and <span style="text-decoration: underline;"></span><a href="http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/index">cone3d/SDL</a><br />
Other 2D/3D <a href="http://ubuntuforums.org/showthread.php?p=3635764#post3635764">frameworks...</a> (incl. a link to <a href="http://ubuntuforums.org/showthread.php?p=5522260#post5522260">panda3d</a>)<br />
<hr style="height: 2px; width: 100%;" /><br />
<span style="color: #cc0000; font-weight: bold;">[ Note 8 ]</span>, Make beautiful graphics with Cairo Graphics <br />
Define <a href="http://en.wikipedia.org/wiki/Cairo_graphics" style="background-color: #cccccc;">Cairo graphics...</a> <a href="http://cairographics.org/" style="background-color: #cccccc;">Homepage...</a><br />
<br />
<a href="http://cairographics.org/samples/">http://cairographics.org/samples/</a> <br />
<br />
<a href="http://www.tortall.net/mu/wiki/CairoTutorial">Cairo tutorial...</a><br />
<br />
MacSlow’s Cairo-Clock (a good example)<br />
<a href="http://macslow.thepimp.net/?page_id=23">http://macslow.thepimp.net/?page_id=23</a><br />
<br />
Study also: <a href="http://en.wikipedia.org/wiki/OpenVG">OpenVG...</a><br />
<hr style="height: 2px; width: 100%;" /> <span style="color: #cc0000; font-weight: bold;"><br />
[ Note 9 ]</span>, Gallium 3D, a new superior graphics engine for Unix/Linux<br />
Define <a href="http://en.wikipedia.org/wiki/Gallium_3D" style="background-color: #33ff33;">Gallium 3D...</a> <a href="http://www.tungstengraphics.com/wiki/index.php/Gallium3D" style="background-color: silver;">Homepage...</a><br />
<span style="text-decoration: underline;"></span><br />
<a href="http://jrfonseca.blogspot.com/2008/04/gallium3d-introduction.html">Gallium 3D introduction...</a><br />
<br />
Study also: <a href="http://zrusin.blogspot.com/2007/09/gallium3d.html">http://zrusin.blogspot.com</a> and <a href="http://aseigo.blogspot.com/">http://aseigo.blogspot.com</a><br />
+ there's some momentum to put <a href="http://clutter-project.org/">Clutter...</a> with its advanced graphics to the upcoming GNOME 3.0. Really nice.<br />
<span style="text-decoration: underline;"></span> <hr style="height: 2px; width: 100%;" /><span style="color: #cc0000; font-weight: bold;"></span><span style="color: #cc0000; font-weight: bold;"><br />
[ Note 10 ]</span>, Programming with the Boost c++ library<br />
Define <a href="http://en.wikipedia.org/wiki/Boost_C%2B%2B_Libraries" style="background-color: #cccccc;">Boost C++...</a> <a href="http://www.boost.org/" style="background-color: #cccccc;">Homepage...</a><br />
<br />
Study: <a href="http://ubuntuforums.org/showthread.php?p=5164645#post5164645">http://ubuntuforums.org/#post5164645</a><br />
<br />
<a href="http://www.boost.org/doc/libs">Boost.org</a><br />
<hr style="height: 2px; width: 100%;" /><span style="color: #cc0000; font-weight: bold;"><br />
[ Note 11 ]</span>, Other important programming resources: <a href="http://www.futuredesktop.org/opportunities.html">http://www.futuredesktop.org/opportunities.html</a><br />
Kernel, driver and module programmer's heaven: <a href="http://www.futuredesktop.org/kernel.html">http://www.futuredesktop.org/kernel.html</a><br />
<br />
<hr style="height: 2px; width: 100%;" /><br />
<span style="color: #cc0000; font-weight: bold;">[ Note 12 ]</span>, Essential <a href="http://en.wikipedia.org/wiki/Manual_page_%28Unix%29">manual pages...</a> that we developers often forget to install and use.<br />
<br />
What manual pages does Ubuntu (or any other distro) offer?<br />
$ <span style="color: #009900;">aptitude search manpages</span><br />
...<br />
manpages - Manual pages about using a GNU/Linux system<br />
<span style="font-weight: bold;">manpages-dev</span> - Manual pages about using GNU/Linux for development<br />
<span style="font-weight: bold;">manpages-posix</span> - Manual pages about using POSIX system<br />
<span style="font-weight: bold;">manpages-posix-dev</span> - Manual pages about using a POSIX system for development<br />
<br />
Install all manpages*dev packages <br />
$ <span style="color: #009900;">sudo</span><span style="color: #009900;"> aptitude </span><span style="color: #009900;">install manpages-dev manpages-posix-dev</span><br />
<br />
Note: This command vill tell you what manual sections (1 - 8 ) the package covers.<br />
$ <span style="color: #009900;"> aptitude </span><span style="color: #009900;">show manpages-posix-dev</span><br />
<br />
Now search help: <br />
$ man 3 fprintf <br />
$ man sqrt <br />
$ man pthread_create<br />
$ man sem_init<br />
<br />
$ man 3 socket<br />
$ man 7 pthreads<br />
$ man 7 sem_overview<br />
<br />
Use also whatis and apropos commands (eg. to reveal the section number)<br />
$ whatis pthread_create<br />
<br />
$ apropos pthread_create<br />
$ apropos pthread<br />
<hr style="height: 2px; width: 100%;" /><br />
<span style="color: #cc0000; font-weight: bold;">[ Note 13 ]</span>, "How to become a real hacker" by Eric S. Raymond, updated 2008 version.<br />
<a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html">http://www.catb.org/~esr/faqs/hacker-howto.html</a><br />
<hr style="height: 2px; width: 100%;" /><br />
<span style="color: #cc0000; font-weight: bold;">[ Note 14 ]</span>, A tip for zooming text in Code::Blocks IDE.<br />
Press <span style="color: #33ccff;">CNTR</span> + NUMPAD <span style="color: #33ccff;">+</span> or NUMPAD <span style="color: #33ccff;">-</span> keys to zoom the text.<br />
NUMPAD +/- are tangents on the numerical keypad.<br />
<hr style="height: 2px; width: 100%;" /><br />
<span style="color: #cc0000; font-weight: bold;">[ Note 15 ]</span>, Make your machine talk. YES TALK !<br />
Define <a href="http://en.wikipedia.org/wiki/Speech_synthesis" style="background-color: #cccccc;">TTS, Text To Speech...</a><br />
<br />
Read: <a href="http://ubuntuforums.org/showthread.php?t=291919">http://ubuntuforums.org/showthread.php?t=291919</a><br />
<br />
Simple examples using espeak:<br />
$ <span style="color: #006600;">espeak "Hi, Hi Joe. How are you today?"</span><br />
$ <span style="color: #006600;">echo "I beg your pardon, could you help me to find this address." | espeak<br />
</span><br />
$ <span style="color: #006600;">echo "All your base are belong to us. Do you agree?" | espeak -v en-us -p 10 -s 140<br />
<span style="color: #006600;"></span><br />
</span>Speak french<span style="color: #006600;"><br />
</span>$<span style="color: #006600;"><span style="color: #006600;"> echo "</span></span><a href="" lang="fr" style="color: #006600;">Avez-vous un frère ou une soeur?</a><a href="" lang="fr" style="color: #006600;">" | espeak -v fr </a><br />
<br />
One more example: Speak the "ls" command's manual page, paragraphs NAME, DESCRIPTION and SEE ALSO.<br />
$ <span style="color: green;">zcat /usr/share/man/man1/ls.1.gz | nroff -man | col -b | sed -e '/./{H;$!d;}' -e 'x;/NAME/b' -e '/DESCRIPTION/b' -e '/SEE ALSO/b' -e d | espeak -p 30 -s 135 -l 10 -v en+3<br />
<br />
</span>List available voices (languages)<span style="color: #006600;"><br />
</span>$<span style="color: #006600;"> espeak --voices<br />
</span>$ <span style="color: #006600;">man espeak<br />
<br />
</span>Define<span style="color: #006600;"> </span><a href="http://en.wikipedia.org/wiki/Speech_recognition" style="background-color: #cccccc;">Speech Recognition...</a><span style="color: #006600;"><br />
</span>Study the <span style="font-weight: bold;">The Julius voice recognition system and PerlBox voice commander</span><span style="color: #006600;"><br />
<a href="http://bloc.eurion.net/archives/2008/writing-a-command-and-control-application-with-voice-recognition/">Writing a command and control application with Julius voice recognition...</a></span><span style="color: #006600;"><br />
<br />
</span> <hr style="height: 2px; width: 100%;" /><br />
<span style="color: #cc0000; font-weight: bold;">[ Note 16 ] </span>,77 useful Linux commands.<br />
<a href="http://searchenterpriselinux.techtarget.com/generic/0,295582,sid39_gci1282259,00.html">http://searchenterpriselinux.techtarget.com/...</a><br />
<hr style="height: 2px; width: 100%;" /><br />
<span style="color: #cc0000; font-weight: bold;">[ Note 17 ]</span>, <br />
Windows converts, read this: <a href="http://ubuntuforums.org/showthread.php?t=554070">http://ubuntuforums.org/showthread.php?t=554070</a><br />
All users, read the <span style="font-weight: bold;">sticky</span> threads: <a href="http://ubuntuforums.org/forumdisplay.php?f=39"><span style="text-decoration: underline;">http://ubuntuforums.org/forumdisplay.php?f=39</span></a><br />
<hr style="height: 2px; width: 100%;" /><br />
<span style="color: #cc0000; font-weight: bold;">[ Note 18 ]</span>, <br />
Learn by studying the existing source code of applications in the Ubuntu distribution.<br />
<span style="font-weight: bold;">A real world example:</span> How do I implement a code that can distinguish between real files and file links (symbolic and hard links)?<br />
Answer: Study the source code of the "readlink" command.<br />
<br />
But first, what package the readlink belongs to?<br />
$ <span style="color: #009900;">apt-cache search readlink</span><br />
coreutils - it is. The GNU core utilities package.<br />
<br />
<span style="color: #999999;">[ Note: You must activate the source code repository in the Software Sources dialog. You will find it in the Administration menu. Activate or add the deb-src lines.</span><br style="color: #999999;" /> <span style="color: #999999;">Refresh the package list in your pc (sudo apt-get update) ], then <br />
<br />
</span>Apt-get the source. <br style="color: #999999;" /> $ <span style="color: #009900;">apt-get source coreutils</span><br />
$ <span style="color: green;">cd coreutils-6.10<br />
</span><br />
Locate the "readlink" function and all places it's been called from <br />
$ <span style="color: green;">grep -R readlink *</span><br />
<br />
And study the code ;-)<br />
<br />
I took this example from Ubuntuforums.org, <a href="http://ubuntuforums.org/showthread.php?p=5041297#post5041297">post 5041297...</a><br />
-------------------<br />
<br />
<span style="font-weight: bold;">A second example.</span><br />
I want to make some improvements to the GNOME's <a href="http://www.futuredesktop.org/jaunty/images/picture8aa.png">Disk-Mounter applet</a>. It's an applet you have on the desktop panel.<br />
Where's the source? Some digging reveals that the package name is "gnome-applets".<br />
<br />
Get the source.<br />
$ <span style="color: #009900;">mkdir -p $HOME/code && cd $HOME/code</span><br />
$ <span style="color: #009900;">apt-get source gnome-applets<br />
<br />
</span>Use <span style="color: #009900;">build-dep </span>to install dependencies so we can compile the code.<span style="color: #009900;"><br />
</span>$ <span style="color: #009900;">sudo apt-get build-dep </span><span style="color: #009900;">gnome-applets</span><br />
<br />
$ <span style="color: #009900;">cd gnome-applets-2.26*</span><br />
<br />
Configure and compile with the normal mantra; <span style="font-weight: bold;">./configure</span> && <span style="font-weight: bold;">make</span>. <br />
Install with <span style="font-weight: bold;">sudo make install.</span><br />
<br />
The code of the Disk Mounter is in <br />
$ <span style="color: #009900;">cd drivemount</span><br />
<br />
Make your changes and type "<span style="font-weight: bold;">make</span>" to recompile it.<br />
Type "sudo make install" to install it.<br />
<br />
<hr style="height: 2px; width: 100%;" /><span style="color: #cc0000; font-weight: bold;"><br />
[ Note 19 ]</span>, I want to compile program XX from source, but it has too many dependencies.<br />
<br />
Study the above note (Note 18).<br />
Use <span style="color: #009900;">build-dep </span>to install *-dev files and dependencies (if the repo has a package for it).<br />
<span style="color: #cc0000; font-weight: bold;"></span><br />
$ <span style="color: #009900;">sudo apt-get build-dep XX</span><br />
<br />
Then compile XX from source.<br />
<br />
<hr style="height: 2px; width: 100%;" /><span style="color: #cc0000; font-weight: bold;"><br />
[ Note 20 ]</span>, Ubuntu development and <a href="https://wiki.ubuntu.com/MOTU">MOTU</a> videos<br />
<span style="color: #cc0000; font-weight: bold;"></span><br />
<a href="http://www.youtube.com/results?search_query=Learning+MOTU">Learning MOTU: Patching and packaging...</a> (<a href="http://videos.ubuntu.com/motuvideos/">altern. url...</a>) <br />
<br />
Ubuntu <a href="http://youtube.com/ubuntudevelopers">developers...</a> Other <a href="https://wiki.ubuntu.com/MOTU/Videos">MOTU videos...</a><br />
<br />
+ Read the <a href="http://www.debian.org/doc/maint-guide/">Debian maintainer's guide...</a><span style="color: #cc0000; font-weight: bold;"><br />
</span><br />
<hr style="height: 2px; width: 100%;" /><span style="color: #cc0000; font-weight: bold;"><br />
[ Note 21]</span>, <br />
Some really good music for a lonely developer and programmer: <a href="http://www.jamendo.com/en/artist/Aavepyora_%282%29">Aavepyörä</a>'s Album <a href="http://www.jamendo.com/en/album/14861">Goddess Guerrilla.</a><br />
Rhythmbox Media Player can search and download music directly from <a href="http://www.magnatune.com/">Magnatune...</a> and <a href="http://www.jamendo.com/en/albums">Jamendo...</a><br />
<br />
<a href="http://bildr.no/view/203206"><img alt="Music" src="http://bildr.no/thumb/203206.jpeg" style="border: 0px solid; height: 93px; width: 150px;" /></a></nothing>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com3tag:blogger.com,1999:blog-4276715425787171951.post-25461104526933530592009-09-16T11:16:00.000+05:302009-09-16T11:16:11.234+05:30good morningtoday, i started to read linux 0.01 code. but to understand boot/ directory under it, i have to learn gnu assembly.<br />
<br />
So, while i m learning GAS, enjoy your stay here.<br />
<br />
if u like reading kernel code too, download it from <a href="http://www.kernel.org/pub/linux/kernel/Historic/">here</a>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com0tag:blogger.com,1999:blog-4276715425787171951.post-18294710420294662622009-09-14T10:32:00.000+05:302009-09-14T10:32:31.905+05:30How-To: Compile and Install Code::Blocks from Source in Debian Lenny<a href="http://www.codeblocks.org/">Code::Blocks</a> is a complete, cross-platform integrated development environment for C and C++, built using the <span style="font-style: italic;">wxWidgets</span> toolkit. Code::Blocks is available on Linux, Windows and OS X, so you may find it useful on Linux if you switched and are already used to it or an IDE like Dev-C++, for example.<br />
<br />
<a href="http://2.bp.blogspot.com/_D1EpnOVJuA8/SWuje1ZFLoI/AAAAAAAABpM/dJ9aoclUmy0/s1600-h/codeblocks03.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5290501937400458882" src="http://2.bp.blogspot.com/_D1EpnOVJuA8/SWuje1ZFLoI/AAAAAAAABpM/dJ9aoclUmy0/s400/codeblocks03.png" style="cursor: pointer; display: block; height: 400px; margin: 0px auto 10px; text-align: center; width: 368px;" /></a><br />
The last stable version is 8.02, and was released almost an year ago. Since Code::Blocks is not included in the Debian repositories, I will show in this tutorial how to compile and install it from source in Lenny, the upcoming stable Debian release. Just follow the steps below:<br />
<br />
<span style="font-weight: bold;">1. Download the source and uncompress it</span><br />
Download the source code from the official website, <a href="http://www.codeblocks.org/downloads/6">here</a>, then make sure to switch the current directory to the one where you saved the source and uncompress it using the following command:<br />
<br />
<span style="color: #006600;">tar -xjf codeblocks-8.02-src.tar.bz2</span><br />
<br />
<span style="font-weight: bold;">2. Install the needed dependencies</span><br />
This should be easy since only a few dependencies are needed. First, make sure you have the <span style="font-style: italic;">build-essential</span> meta-package installed, which contains tools like <span style="font-style: italic;">make</span> or <span style="font-style: italic;">g++</span>, needed for compilation:<br />
<br />
<span style="color: #006600;">su</span><br />
<span style="color: #006600;">apt-get install build-essential</span><br />
<br />
Next, install the development packages needed by Code::Blocks:<br />
<br />
<span style="color: #006600;">su</span><br />
<span style="color: #006600;">apt-get install wx-common libwxgtk2.8-dev libgtk2.0-dev</span><br />
<br />
You will also need package <span style="font-style: italic;">zip</span> to build it:<br />
<br />
<span style="color: #006600;">apt-get install zip</span><br />
<br />
<span style="font-weight: bold;">3. Update wx-config to point to wxWidgets 2.8</span><br />
Issue the following command as root:<br />
<br />
<span style="color: #006600;">update-alternatives --config wx-config</span><br />
<br />
What appears should look something like this:<br />
<br />
<span style="color: #006600;"># update-alternatives --config wx-config</span> <span style="color: #006600;"><br />
There are 4 alternatives which provide `wx-config'.</span> <span style="color: #006600;"><br />
Selection Alternative</span> <span style="color: #006600;">-----------------------------------------------</span> <span style="color: #006600;"> <br />
1 /usr/lib/wx/config/base-unicode-release-2.6</span> <span style="color: #006600;"> + <br />
2 /usr/lib/wx/config/gtk2-unicode-release-2.6</span> <span style="color: #006600;"> <br />
3 /usr/lib/wx/config/base-unicode-release-2.8</span> <span style="color: #990000;"><br />
* 4 /usr/lib/wx/config/gtk2-unicode-release-2.8</span><br />
<br />
<span style="color: #006600;">Press enter to keep the default[*], or type selection number:<br />
4</span> <span style="color: #006600;">Using '/usr/lib/wx/config/gtk2-unicode-release-2.8' to provide 'wx-config'.</span><br />
<br />
Select option <span style="font-weight: bold;">4</span> from the list, that is <span style="font-style: italic;">/usr/lib/wx/config/gtk2-unicode-release-2.8</span><br />
<br />
<span style="font-weight: bold;">4. Compile from source and install</span><br />
Make sure the working directory is the uncompressed source of Code::Blocks (<span style="font-style: italic;">codeblocks-8.02</span>) and issue the usual commands:<br />
<br />
<span style="color: #006600;">./configure</span><br />
<span style="color: #006600;">make</span><br />
<span style="color: #006600;">make install</span><br />
<br />
The last one as root.<br />
<br />
<span style="font-weight: bold;">5. Run <span style="font-style: italic;">ldconfig</span> as root</span><br />
Finally, run the <span style="font-style: italic;">ldconfig</span> utility as root to update the links to shared libraries:<br />
<br />
<span style="color: #006600;">su</span><br />
<span style="color: #006600;">ldconfig</span><br />
<br />
Code::Blocks should be now properly installed in <span style="font-style: italic;">/usr/local/bin</span>/ and you can run it using <span style="font-style: italic;">codeblocks</span> from a terminal or from a run dialogue (ALT+F2 and type <span style="font-style: italic;">codeblocks</span> in KDE and GNOME).<br />
<br />
<a href="http://4.bp.blogspot.com/_D1EpnOVJuA8/SWujfDX-9YI/AAAAAAAABpU/RGm9diH9Giw/s1600-h/codeblocks02.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5290501941153953154" src="http://4.bp.blogspot.com/_D1EpnOVJuA8/SWujfDX-9YI/AAAAAAAABpU/RGm9diH9Giw/s400/codeblocks02.png" style="cursor: pointer; display: block; height: 303px; margin: 0px auto 10px; text-align: center; width: 400px;" /></a><a href="http://2.bp.blogspot.com/_D1EpnOVJuA8/SWujfmDKInI/AAAAAAAABpc/PQg6CkX9EZI/s1600-h/codeblocks01.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5290501950461846130" src="http://2.bp.blogspot.com/_D1EpnOVJuA8/SWujfmDKInI/AAAAAAAABpc/PQg6CkX9EZI/s400/codeblocks01.png" style="cursor: pointer; display: block; height: 313px; margin: 0px auto 10px; text-align: center; width: 400px;" /></a>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com2tag:blogger.com,1999:blog-4276715425787171951.post-40454894246955404612009-09-08T20:54:00.002+05:302009-09-08T20:59:13.323+05:30Midpoint Ellipse Algorithm<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_4Mr9PcctaeY/SqZ3mnMZTFI/AAAAAAAAADA/ZNISSaY-HgI/s1600-h/MP_ELLIPSE.png"><img style="cursor: pointer; width: 400px; height: 300px;" src="http://4.bp.blogspot.com/_4Mr9PcctaeY/SqZ3mnMZTFI/AAAAAAAAADA/ZNISSaY-HgI/s400/MP_ELLIPSE.png" alt="" id="BLOGGER_PHOTO_ID_5379118310180342866" border="0" /></a><br /><br /><pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"><code>/*************************************************<br />* Midpoint Ellipse Algorithm *<br />*************************************************<br />* Usage :- Optimized and general method for rasterizing ellipses<br />* Author :- Rooparam Choudhary<br />* Date :- September 1, 2009 [3:15 PM IST]<br />* Place :- Shri Mata Vaishno Devi University<br />* EntryNo :- 2006ECS20<br />*/<br /><br />#include <graphics.h><br />#include <stdlib.h><br />#include <iostream><br />#include <math.h><br />#include <time.h><br /><br />inline void setpixel(int, int);<br />void unionJack(void);<br />void randomUnionJack(int);<br />void ellipseMidpoint(int, int, int, int);<br />inline void draw(int, int, int, int);<br />void wait(void);<br /><br />int MYCOLOR = WHITE;<br />clock_t DELAY = 0;<br /><br />void wait(void) {<br /> clock_t init = clock();<br /> while( (clock() - init) < DELAY)<br /> ;<br />}<br /><br />/* Ellipse drawing algorithm */<br />void ellipseMidpoint(int xc, int yc, int rx, int ry) {<br /> long long int rx_2 = rx*rx, ry_2 = ry*ry;<br /> long long int p = ry_2 - rx_2*ry + (ry_2>>2);<br /> int x = 0, y = ry;<br /> long long int two_ry_2_x = 0, two_rx_2_y = (rx_2<<1)*y;<br /> draw(xc, yc, x, y);<br /> while(two_rx_2_y >= two_ry_2_x){<br /> ++x;<br /> two_ry_2_x += (ry_2<<1);<br /> <br /> p += two_ry_2_x + ry_2;<br /> <br /> if(p >= 0){<br /> --y;<br /> two_rx_2_y -= (rx_2<<1);<br /> <br /> p -= two_rx_2_y ;<br /> }<br /> wait();<br /> draw(xc, yc, x, y);<br /> }<br /> <br /> p = (long long int)(ry_2*(x+1/2.0)*(x+1/2.0) + rx_2*(y-1)*(y-1) - rx_2*ry_2);<br /> while (y>=0) {<br /> p += rx_2;<br /> --y;<br /> two_rx_2_y -= (rx_2<<1);<br /> p -= two_rx_2_y;<br /> <br /> if(p <= 0) {<br /> ++x;<br /> two_ry_2_x += (ry_2<<1);<br /> p += two_ry_2_x;<br /> }<br /> wait();<br /> draw(xc, yc, x, y);<br /> }<br />}<br /><br />/* Using the symmetry of Ellipse to draw points in other octants */<br />inline void draw(int xc, int yc, int x, int y) {<br /> setpixel(xc+x, yc+y); // Ist Quadrant<br /> setpixel(xc-x, yc+y); // IInd Quadrant<br /> setpixel(xc-x, yc-y); // IIIrd Quadrant<br /> setpixel(xc+x, yc-y); // IVth Quadrant<br />}<br /><br />inline void setpixel(int x, int y){<br /> putpixel(320+x, 240-y, MYCOLOR);<br />}<br /><br />void randomUnionJack(int count){<br /> void DJ(int, int, int);<br /> int xr, yr, clr=0;<br /> srand(time(NULL));<br /> <br /> while(count-- > 0){<br /> xr = -320 + rand()%641;<br /> yr = -240 + rand()%481;<br /> clr = 0;<br /> if(yr > -xr){<br /> if(xr < 0) clr = 3;<br /> else if(yr < 0) clr = 2;<br /> else if(yr > xr) clr = 4;<br /> else if(yr < xr) clr = 1;<br /> }else if(yr < -xr) {<br /> if(xr > 0) clr = 3;<br /> else if(yr > 0) clr = 2;<br /> else if(yr < xr) clr = 4;<br /> else if(yr > xr) clr = 1;<br /> }<br /> DJ(xr, yr, clr);<br /> }<br />}<br /><br />void DJ(int x, int y, int clr){<br /> int shade = 0;<br /> switch(clr){<br /> case 1: shade = RED; break;<br /> case 2: shade = BLUE; break;<br /> case 3: shade = CYAN; break;<br /> case 4: shade = MAGENTA; break;<br /> default: return; break;<br /> }<br /> putpixel(320+x, 240-y, shade);<br />}<br /><br />void unionJack(){<br /> for(int y = 240; y>0; --y) {<br /> int x = -321;<br /><br /> MYCOLOR = BLUE;<br /> while(++x < -y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = CYAN;<br /> while(++x < 0)<br /> { putpixel(320+x, 240-y, MYCOLOR); } <br /> MYCOLOR = MAGENTA;<br /> while(++x < y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = RED;<br /> while(++x < 321)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> }<br /> for(int y = -1; y>-241; --y) {<br /> int x = -321;<br /><br /> MYCOLOR = RED;<br /> while(++x < y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = MAGENTA;<br /> while(++x < 0)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = CYAN;<br /> while(++x < -y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = BLUE;<br /> while(++x < 321)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> }<br />}<br /><br />int main(void) {<br /> int gd = DETECT, gm;<br /> char *author = "Coder:- Rooparam Choudhary";<br /> char *algo = "Midpoint Ellipse Algorithm";<br /> char point[30];<br /> //std::cout << algo << std::endl;<br /> //std::cout << author << std::endl;<br /> initgraph(&gd, &gm, "C:\\");<br /> <br /> setcolor(WHITE);<br /> setbkcolor(GREEN);<br /> outtextxy(320 - textwidth(algo)/2, 5, algo);<br /> outtextxy(getmaxx()-4 -textwidth(author), getmaxy()-20, author);<br /> setcolor(GREEN);<br /> setbkcolor(BLACK);<br /> <br /> setcolor(YELLOW);<br /> // X-axis<br /> line(0, 239, 640, 239);<br /> line(0, 240, 640, 240);<br /> line(0, 241, 640, 241);<br /> // Y-axis<br /> line(319, 0, 319, 480);<br /> line(320, 0, 320, 480);<br /> line(321, 0, 321, 480);<br /> // Y + X = 0<br /> line(80, 0, 560, 480);<br /> // Y - X = 0<br /> line(80, 480, 560, 0);<br /><br /> std::cout << "Enter samples for union jack\n(SHOULD BE GEATER THAN 100K): ";<br /> int samp;<br /> std::cin >> samp;<br /> //unionJack();<br /> randomUnionJack(samp);<br /><br /> setcolor(WHITE);<br /> setbkcolor(GREEN);<br /> outtextxy(320 - textwidth(algo)/2, 5, algo);<br /> outtextxy(getmaxx()-4 -textwidth(author), getmaxy()-20, author);<br /> setcolor(GREEN);<br /> setbkcolor(BLACK);<br /><br /> int xc, yc, rx, ry;<br /> <br /> MYCOLOR = WHITE;<br /> std::cout << "\nDelay Interval [0 - 100]\t Recommended: 20\n\n";<br /> std::cout << "Enter the coordinates of ellipse center and it's two axes and delay\n[xc yc rx ry delay] (\'-400\' to exit) : ";<br /><br /> std::cin >> xc;<br /> while(xc != -400) {<br /> std::cin >> yc >> rx >> ry >> DELAY;<br /> sprintf(point, "(%3d, %3d) %3d %3d", xc, yc, rx, ry);<br /> setpixel(xc, yc);<br /> line(320+xc, 240-yc, 320+xc+rx, 240-yc);<br /> line(320+xc, 240-yc, 320+xc, 240-yc-ry);<br /> outtextxy(320+xc-textwidth(point)/2, 240-yc+2, point);<br /> ellipseMidpoint(xc, yc, rx, ry);<br /><br /> setcolor(WHITE);<br /> setbkcolor(GREEN);<br /> outtextxy(320 - textwidth(algo)/2, 5, algo);<br /> outtextxy(getmaxx()-4 -textwidth(author), getmaxy()-20, author);<br /> setcolor(GREEN);<br /> setbkcolor(BLACK);<br /><br /> std::cout << "[xc yc rx ry delay] (\'-400\' to exit) : ";<br /> std::cin >> xc;<br /> }<br /><br /> closegraph();<br /> return 0;<br />}<br /><br /></code></pre>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com3tag:blogger.com,1999:blog-4276715425787171951.post-41847122376305809872009-09-08T20:48:00.001+05:302009-09-08T20:53:48.706+05:30Midpoint Circle Algorithm<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_4Mr9PcctaeY/SqZ2opCin3I/AAAAAAAAAC4/CsC4f3-9BDk/s1600-h/MP_CIRCLE.png"><img style="cursor: pointer; width: 400px; height: 300px;" src="http://1.bp.blogspot.com/_4Mr9PcctaeY/SqZ2opCin3I/AAAAAAAAAC4/CsC4f3-9BDk/s400/MP_CIRCLE.png" alt="" id="BLOGGER_PHOTO_ID_5379117245523992434" border="0" /></a><br /><br /><pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"><code>/*************************************************<br />* Midpoint Circle Algorithm *<br />*************************************************<br />* Usage :- Optimized and general method for rasterizing circles<br />* Author :- Rooparam Choudhary<br />* Date :- August 29, 2009 [3:40 PM IST]<br />* Place :- Shri Mata Vaishno Devi University<br />* EntryNo :- 2006ECS20<br />*/<br /><br />#include <graphics.h><br />#include <stdlib.h><br />#include <iostream><br />#include <math.h><br />#include <time.h><br /><br />inline void setpixel(int, int);<br />void unionJack(void);<br />void randomUnionJack(int);<br />void circleMidpoint(int, int, int);<br />inline void draw(int, int, int, int);<br />void wait(void);<br /><br />int MYCOLOR = WHITE;<br />clock_t DELAY = 0;<br /><br />void wait(void) {<br /> clock_t init = clock();<br /> while( (clock() - init) < DELAY)<br /> ;<br />}<br /><br />/* Circle drawing algorithm */<br />void circleMidpoint(int xc, int yc, int r) {<br /> int p = 1 - r;<br /> int x = 0, y = r;<br /> do{<br /> draw(xc, yc, x, y);<br /> ++x;<br /> if (p < 0)<br /> p += 1 + (x<<1);<br /> else{<br /> --y;<br /> p += 1 - ((y-x) << 1) ;<br /> }<br /> wait();<br /> }while(y >= x);<br />}<br /><br />/* Using the symmetry of Circle to draw points in other octants */<br />inline void draw(int xc, int yc, int x, int y) {<br /> setpixel(xc+x, yc+y); // Ist Octant<br /> setpixel(xc+y, yc+x); // IInd Octant<br /> setpixel(xc-y, yc+x); // IIIrd Octant<br /> setpixel(xc-x, yc+y); // IVth Octant<br /> setpixel(xc-x, yc-y); // Vth Octant<br /> setpixel(xc-y, yc-x); // VIth Octant<br /> setpixel(xc+y, yc-x); // VIIth Octant<br /> setpixel(xc+x, yc-y); // VIIIth Octant<br />}<br /><br />inline void setpixel(int x, int y){<br /> putpixel(320+x, 240-y, MYCOLOR);<br />}<br /><br />void randomUnionJack(int count){<br /> void DJ(int, int, int);<br /> int xr, yr, clr=0;<br /> srand(time(NULL));<br /> <br /> while(count-- > 0){<br /> xr = -320 + rand()%641;<br /> yr = -240 + rand()%481;<br /> clr = 0;<br /> if(yr > -xr){<br /> if(xr < 0) clr = 3;<br /> else if(yr < 0) clr = 2;<br /> else if(yr > xr) clr = 4;<br /> else if(yr < xr) clr = 1;<br /> }else if(yr < -xr) {<br /> if(xr > 0) clr = 3;<br /> else if(yr > 0) clr = 2;<br /> else if(yr < xr) clr = 4;<br /> else if(yr > xr) clr = 1;<br /> }<br /> DJ(xr, yr, clr);<br /> }<br />}<br /><br />void DJ(int x, int y, int clr){<br /> int shade = 0;<br /> switch(clr){<br /> case 1: shade = RED; break;<br /> case 2: shade = BLUE; break;<br /> case 3: shade = CYAN; break;<br /> case 4: shade = MAGENTA; break;<br /> default: return; break;<br /> }<br /> putpixel(320+x, 240-y, shade);<br />}<br /><br />void unionJack(){<br /> for(int y = 240; y>0; --y) {<br /> int x = -321;<br /><br /> MYCOLOR = BLUE;<br /> while(++x < -y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = CYAN;<br /> while(++x < 0)<br /> { putpixel(320+x, 240-y, MYCOLOR); } <br /> MYCOLOR = MAGENTA;<br /> while(++x < y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = RED;<br /> while(++x < 321)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> }<br /> for(int y = -1; y>-241; --y) {<br /> int x = -321;<br /><br /> MYCOLOR = RED;<br /> while(++x < y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = MAGENTA;<br /> while(++x < 0)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = CYAN;<br /> while(++x < -y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = BLUE;<br /> while(++x < 321)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> }<br />}<br /><br />int main(void) {<br /> int gd = DETECT, gm;<br /> char *author = "Coder:- Rooparam Choudhary";<br /> char *algo = "Midpoint Circle Algorithm";<br /> char point[30];<br /> //std::cout << algo << std::endl;<br /> //std::cout << author << std::endl;<br /> initgraph(&gd, &gm, "C:\\");<br /> <br /> setcolor(WHITE);<br /> setbkcolor(GREEN);<br /> outtextxy(320 - textwidth(algo)/2, 5, algo);<br /> outtextxy(getmaxx()-4 -textwidth(author), getmaxy()-20, author);<br /> setcolor(GREEN);<br /> setbkcolor(BLACK);<br /> <br /> setcolor(YELLOW);<br /> // X-axis<br /> line(0, 239, 640, 239);<br /> line(0, 240, 640, 240);<br /> line(0, 241, 640, 241);<br /> // Y-axis<br /> line(319, 0, 319, 480);<br /> line(320, 0, 320, 480);<br /> line(321, 0, 321, 480);<br /> // Y + X = 0<br /> line(80, 0, 560, 480);<br /> // Y - X = 0<br /> line(80, 480, 560, 0);<br /><br /> std::cout << "Enter samples for union jack\n(SHOULD BE GEATER THAN 100K): ";<br /> int samp;<br /> std::cin >> samp;<br /> //unionJack();<br /> randomUnionJack(samp);<br /><br /> setcolor(WHITE);<br /> setbkcolor(GREEN);<br /> outtextxy(320 - textwidth(algo)/2, 5, algo);<br /> outtextxy(getmaxx()-4 -textwidth(author), getmaxy()-20, author);<br /> setcolor(GREEN);<br /> setbkcolor(BLACK);<br /><br /> int xc, yc, r;<br /> <br /> MYCOLOR = WHITE;<br /> std::cout << "\nDelay Interval [0 - 100]\t Recommended: 20\n\n";<br /> std::cout << "Enter the coordinates of circle center and it's radius and delay\n[xc yc r delay] (\'-400\' to exit) : ";<br /><br /> std::cin >> xc;<br /> while(xc != -400) {<br /> std::cin >> yc >> r >> DELAY;<br /> sprintf(point, "(%3d, %3d) %3d", xc, yc, r);<br /> setpixel(xc, yc);<br /> line(320+xc, 240-yc, 320+xc+r, 240-yc);<br /> outtextxy(320+xc-textwidth(point)/2, 240-yc+2, point);<br /> circleMidpoint(xc, yc, r);<br /><br /> setcolor(WHITE);<br /> setbkcolor(GREEN);<br /> outtextxy(320 - textwidth(algo)/2, 5, algo);<br /> outtextxy(getmaxx()-4 -textwidth(author), getmaxy()-20, author);<br /> setcolor(GREEN);<br /> setbkcolor(BLACK);<br /><br /> std::cout << "[xc yc r delay] (\'-400\' to exit) : ";<br /> std::cin >> xc;<br /> }<br /><br /> closegraph();<br /> return 0;<br />}<br /><br /></code></pre>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com0tag:blogger.com,1999:blog-4276715425787171951.post-36060220151534004212009-09-08T20:35:00.002+05:302009-09-08T20:44:56.463+05:30Simple Circle Drawing Algorithm<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_4Mr9PcctaeY/SqZzywgJY6I/AAAAAAAAACw/e6rDHZ41vWk/s1600-h/Circle.png"><img style="cursor: pointer; width: 400px; height: 300px;" src="http://1.bp.blogspot.com/_4Mr9PcctaeY/SqZzywgJY6I/AAAAAAAAACw/e6rDHZ41vWk/s400/Circle.png" alt="" id="BLOGGER_PHOTO_ID_5379114120791024546" border="0" /></a><br /><br /><br /><pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"><code>/*************************************************<br />* Simple Circle Drawing Algorithm *<br />*************************************************<br />* Usage :- Simple and general method for rasterizing circles<br />* Author :- Rooparam Choudhary<br />* Date :- August 29, 2009 [12:40 PM IST]<br />* Place :- Shri Mata Vaishno Devi University<br />* EntryNo :- 2006ECS20<br />*/<br /><br />#include <graphics.h><br />#include <stdlib.h><br />#include <iostream><br />#include <math.h><br />#include <time.h><br /><br />#define ROUND(x) ((x>0)?(int)(x+0.5):(int)(x-0.5))<br />#define PI 3.14159265<br /><br />inline void setpixel(int, int);<br />void unionJack(void);<br />void simpleCircle(float, float, float);<br />inline void draw(float, float, float, float);<br />void wait(void);<br />void randomUnionJack(int);<br /><br />int MYCOLOR = WHITE;<br />clock_t DELAY = 0;<br /><br />void randomUnionJack(int count){<br /> void DJ(int, int, int);<br /> int xr, yr, clr=0;<br /> srand(time(NULL));<br /> <br /> while(count-- > 0){<br /> xr = -320 + rand()%641;<br /> yr = -240 + rand()%481;<br /> clr = 0;<br /> if(yr > -xr){<br /> if(xr < 0) clr = 3;<br /> else if(yr < 0) clr = 2;<br /> else if(yr > xr) clr = 4;<br /> else if(yr < xr) clr = 1;<br /> }else if(yr < -xr) {<br /> if(xr > 0) clr = 3;<br /> else if(yr > 0) clr = 2;<br /> else if(yr < xr) clr = 4;<br /> else if(yr > xr) clr = 1;<br /> }<br /> DJ(xr, yr, clr);<br /> }<br />}<br /><br />void DJ(int x, int y, int clr){<br /> int shade = 0;<br /> switch(clr){<br /> case 1: shade = RED; break;<br /> case 2: shade = BLUE; break;<br /> case 3: shade = CYAN; break;<br /> case 4: shade = MAGENTA; break;<br /> default: return; break;<br /> }<br /> putpixel(320+x, 240-y, shade);<br />}<br /><br />void wait(void) {<br /> clock_t init = clock();<br /> while( (clock() - init) < DELAY)<br /> ;<br />}<br /><br />/* Circle drawing algorithm */<br />void simpleCircle(float xc, float yc, float radius) {<br /> float step = 1.0f / radius, theta = 0.0f;<br /> float x = radius, y = 0.0f;<br /> do{<br /> draw(xc, yc, x, y);<br /> theta += step;<br /> x = radius*cos(theta);<br /> y = radius*sin(theta);<br /> wait();<br /> }while(theta <= PI / 4.0f);<br />}<br /><br />/* Using the symmetry of Circle to draw points in other octants */<br />inline void draw(float xc, float yc, float x, float y) {<br /> setpixel(ROUND(xc+x), ROUND(yc+y)); // Ist Octant<br /> setpixel(ROUND(xc+y), ROUND(yc+x)); // IInd Octant<br /> setpixel(ROUND(xc-y), ROUND(yc+x)); // IIIrd Octant<br /> setpixel(ROUND(xc-x), ROUND(yc+y)); // IVth Octant<br /> setpixel(ROUND(xc-x), ROUND(yc-y)); // Vth Octant<br /> setpixel(ROUND(xc-y), ROUND(yc-x)); // VIth Octant<br /> setpixel(ROUND(xc+y), ROUND(yc-x)); // VIIth Octant<br /> setpixel(ROUND(xc+x), ROUND(yc-y)); // VIIIth Octant<br />}<br /><br />inline void setpixel(int x, int y){<br /> putpixel(320+x, 240-y, MYCOLOR);<br />}<br /><br />void unionJack(){<br /> for(int y = 240; y>0; --y) {<br /> int x = -321;<br /><br /> MYCOLOR = BLUE;<br /> while(++x < -y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = CYAN;<br /> while(++x < 0)<br /> { putpixel(320+x, 240-y, MYCOLOR); } <br /> MYCOLOR = MAGENTA;<br /> while(++x < y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = RED;<br /> while(++x < 321)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> }<br /> for(int y = -1; y>-241; --y) {<br /> int x = -321;<br /><br /> MYCOLOR = RED;<br /> while(++x < y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = MAGENTA;<br /> while(++x < 0)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = CYAN;<br /> while(++x < -y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = BLUE;<br /> while(++x < 321)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> }<br />}<br /><br />int main(void) {<br /> int gd = DETECT, gm;<br /> char *author = "Coder:- Rooparam Choudhary";<br /> char *algo = "Simple Circle Drawing Algorithm";<br /> char point[30];<br /> std::cout << algo << std::endl;<br /> std::cout << author << std::endl;<br /> initgraph(&gd, &gm, "C:\\");<br /> <br /> setcolor(WHITE);<br /> setbkcolor(GREEN);<br /> outtextxy(320 - textwidth(algo)/2, 5, algo);<br /> outtextxy(getmaxx()-4 -textwidth(author), getmaxy()-20, author);<br /> setcolor(GREEN);<br /> setbkcolor(BLACK);<br /> <br /> setcolor(YELLOW);<br /> // X-axis<br /> line(0, 239, 640, 239);<br /> line(0, 240, 640, 240);<br /> line(0, 241, 640, 241);<br /> // Y-axis<br /> line(319, 0, 319, 480);<br /> line(320, 0, 320, 480);<br /> line(321, 0, 321, 480);<br /> // Y + X = 0<br /> line(80, 0, 560, 480);<br /> // Y - X = 0<br /> line(80, 480, 560, 0);<br /><br /> std::cout << "Enter samples for union jack\n(SHOULD BE GEATER THAN 100K): ";<br /> int samp;<br /> std::cin >> samp;<br /> //unionJack();<br /> randomUnionJack(samp);<br /><br /> setcolor(WHITE);<br /> setbkcolor(GREEN);<br /> outtextxy(320 - textwidth(algo)/2, 5, algo);<br /> outtextxy(getmaxx()-4 -textwidth(author), getmaxy()-20, author);<br /> setcolor(GREEN);<br /> setbkcolor(BLACK);<br /><br /> float xc, yc, r;<br /> <br /> MYCOLOR = WHITE;<br /> std::cout << "Enter \'-400\' to exit\n";<br /> std::cout << "Enter Delay: ";<br /> std::cin >> DELAY;<br /> std::cout << "Enter the coordinates of circle center and it's radius: [xc yc r]\n";<br /><br /> std::cin >> xc;<br /> while((int)xc != (int)-400.0f ) {<br /> std::cin >> yc >> r;<br /> sprintf(point, "(%4.1f, %4.1f) %4.1f", xc, yc, r);<br /> setpixel(ROUND(xc), ROUND(yc));<br /> line(320+ROUND(xc), 240-ROUND(yc), 320+ROUND(xc+r), 240-ROUND(yc));<br /> outtextxy(320+ROUND(xc)-textwidth(point)/2, 240-ROUND(yc)+2, point);<br /> simpleCircle(xc, yc, r);<br /><br /> setcolor(WHITE);<br /> setbkcolor(GREEN);<br /> outtextxy(320 - textwidth(algo)/2, 5, algo);<br /> outtextxy(getmaxx()-4 -textwidth(author), getmaxy()-20, author);<br /> setcolor(GREEN);<br /> setbkcolor(BLACK);<br /><br /> std::cin >> xc;<br /> }<br /><br /> closegraph();<br /> return 0;<br />}<br /><br /></code></pre>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com2tag:blogger.com,1999:blog-4276715425787171951.post-52931216317760687032009-09-08T20:20:00.003+05:302009-09-08T20:32:04.836+05:30Bresenham's Line Drawing Algorithm<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_4Mr9PcctaeY/SqZwLWpK1rI/AAAAAAAAACo/F10Lw2d5TQw/s1600-h/Bresenham.png"><img style="cursor: pointer; width: 400px; height: 300px;" src="http://4.bp.blogspot.com/_4Mr9PcctaeY/SqZwLWpK1rI/AAAAAAAAACo/F10Lw2d5TQw/s400/Bresenham.png" alt="" id="BLOGGER_PHOTO_ID_5379110145299764914" border="0" /></a><br /><br /><pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code>/*************************************************<br /> * Bresenham's Line Drawing Algorithm *<br /> *************************************************<br /> * Usage :- Optimized and general method for rasterizing lines and triangles<br /> * Author :- Rooparam Choudhary<br /> * Date :- August 29, 2009<br /> * Place :- Shri Mata Vaishno Devi University<br /> * EntryNo :- 2006ECS20<br /> */<br /><br />#include <graphics.h><br />#include <conio.h><br />#include <stdlib.h><br />#include <iostream><br />#include <math.h><br /><br />inline void setpixel(int, int);<br />void BHM(int, int, int, int);<br />void drawLine(int, int, int, int);<br />void unionJack(void);<br />void hexagon(int, int);<br />void randomUnionJack(int);<br /><br />int MYCOLOR = WHITE;<br />int INVERSE = 0; // 0 : false 1 : true<br />int SIGN = 0; // 0 : y = x 1 : y = -x<br /><br />inline void setpixel(int x, int y){<br /> if(INVERSE){<br /> if(SIGN)<br /> putpixel(320-y, 240+x, MYCOLOR);<br /> else<br /> putpixel(320+y, 240-x, MYCOLOR);<br /> } else<br /> putpixel(320+x, 240-y, MYCOLOR);<br />}<br /><br />void randomUnionJack(int count){<br /> void DJ(int, int, int);<br /> int xr, yr, clr=0;<br /> srand(time(NULL));<br /> <br /> while(count-- > 0){<br /> xr = -320 + rand()%641;<br /> yr = -240 + rand()%481;<br /> clr = 0;<br /> if(yr > -xr){<br /> if(xr < 0) clr = 3;<br /> else if(yr < 0) clr = 2;<br /> else if(yr > xr) clr = 4;<br /> else if(yr < xr) clr = 1;<br /> }else if(yr < -xr) {<br /> if(xr > 0) clr = 3;<br /> else if(yr > 0) clr = 2;<br /> else if(yr < xr) clr = 4;<br /> else if(yr > xr) clr = 1;<br /> }<br /> DJ(xr, yr, clr);<br /> }<br />}<br /><br />void DJ(int x, int y, int clr){<br /> int shade = 0;<br /> switch(clr){<br /> case 1: shade = RED; break;<br /> case 2: shade = BLUE; break;<br /> case 3: shade = CYAN; break;<br /> case 4: shade = MAGENTA; break;<br /> default: return; break;<br /> }<br /> putpixel(320+x, 240-y, shade);<br />}<br /><br />void BHM(int x0, int y0, int x1, int y1){<br /> int twoDY = 2*(y1-y0), twoDX = 2*(x1-x0), DX = x1-x0;<br /> int incY = ((twoDY < 0) ? -1 : 1);<br /> twoDY = abs(twoDY);<br /> int p = twoDY - DX; int x = x0, y = y0;<br /><br /> setpixel(x, y);<br /><br /> while(x < x1) {<br /> ++x;<br /> if(!(p<0)) {<br /> y += incY;<br /> p -= twoDX;<br /> }<br /> p += twoDY;<br /> setpixel(x, y);<br /> }<br />}<br /><br />void drawLine(int x0, int y0, int x1, int y1) {<br /> INVERSE = 0;<br /> SIGN = 0;<br /> float m = 0;<br /> int t;<br /> int infinity = (x1 == x0);<br /> <br /> if(!infinity)<br /> m = (y1-y0) / (float)(x1-x0);<br /> if(m < 0)<br /> SIGN = 1;<br /><br /> if(infinity || fabs(m) > 1) {<br /> INVERSE = 1;<br /><br /> if(SIGN)<br /> { t = -x0; x0 = -y0; y0 = t;<br /> t = -x1; x1 = -y1; y1 = t; } <br /> else<br /> { t = x0; x0 = y0; y0 = t;<br /> t = x1; x1 = y1; y1 = t; } <br /> }<br /><br /> if(x1<x0)<br /> BHM(x1, y1, x0, y0);<br /> else<br /> BHM(x0, y0, x1, y1);<br />}<br /><br />void unionJack(){<br /> for(int y = 240; y>0; --y) {<br /> int x = -321;<br /><br /> MYCOLOR = BLUE;<br /> while(++x < -y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = CYAN;<br /> while(++x < 0)<br /> { putpixel(320+x, 240-y, MYCOLOR); } <br /> MYCOLOR = MAGENTA;<br /> while(++x < y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = RED;<br /> while(++x < 321)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> }<br /> for(int y = -1; y>-241; --y) {<br /> int x = -321;<br /><br /> MYCOLOR = RED;<br /> while(++x < y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = MAGENTA;<br /> while(++x < 0)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = CYAN;<br /> while(++x < -y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = BLUE;<br /> while(++x < 321)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> }<br />}<br />void hexagon(int xc, int yc) {<br /> drawLine(xc+60, yc+104, xc+120, yc);<br /> drawLine(xc+60, yc+104, xc+60, yc-104);<br /> drawLine(xc+60, yc+104, xc-60, yc-104);<br /> drawLine(xc+60, yc+104, xc-120, yc);<br /> drawLine(xc+60, yc+104, xc-60, yc+104);<br /> drawLine(xc+120, yc, xc+60, yc-104);<br /> drawLine(xc+120, yc, xc-60, yc-104);<br /> drawLine(xc+120, yc, xc-120, yc);<br /> drawLine(xc+120, yc, xc-60, yc+104);<br /> drawLine(xc+60, yc-104, xc-60, yc-104);<br /> drawLine(xc+60, yc-104, xc-120, yc);<br /> drawLine(xc+60, yc-104, xc-60, yc+104);<br /> drawLine(xc-60, yc-104, xc-120, yc);<br /> drawLine(xc-60, yc-104, xc-60, yc+104);<br /> drawLine(xc-120, yc, xc-60, yc+104);<br />}<br /><br />int main(void) {<br /> int gd = DETECT, gm;<br /> char *author = "Coder:- Rooparam Choudhary";<br /> char *algo = "Bresenham's Line Drawing Algorithm";<br /> char point[30];<br /> std::cout << algo << std::endl;<br /> std::cout << author << std::endl;<br /> initgraph(&gd, &gm, "C:\\");<br /><br /> setcolor(WHITE);<br /> setbkcolor(GREEN);<br /> outtextxy(320 - textwidth(algo)/2, 5, algo);<br /> outtextxy(getmaxx()-4 -textwidth(author), getmaxy()-20, author);<br /> setcolor(GREEN);<br /> setbkcolor(BLACK);<br /><br /> MYCOLOR = GREEN;<br /> // X-axis<br /> drawLine(-320, -1, 320, -1);<br /> drawLine(-320, 0, 320, 0);<br /> drawLine(-320, 1, 320, 1);<br /> // Y-axis<br /> drawLine(-1, 240, -1, -240);<br /> drawLine( 0, 240, 0, -240);<br /> drawLine( 1, 240, 1, -240);<br /> // Y - X = 0<br /> drawLine(-240, -240, 240, 240);<br /> // Y + X = 0<br /> drawLine(-240, 240, 240, -240);<br /><br /> MYCOLOR = BROWN;<br /> hexagon(-160, 120);<br /> hexagon(160, 120);<br /> hexagon(160, -120);<br /> hexagon(-160, -120);<br /> <br /> std::cout << "Enter samples for union jack\n(SHOULD BE GEATER THAN 100K): ";<br /> int samp;<br /> std::cin >> samp;<br /> //unionJack();<br /> randomUnionJack(samp);<br /> <br /> setcolor(WHITE);<br /> setbkcolor(GREEN);<br /> outtextxy(320 - textwidth(algo)/2, 5, algo);<br /> outtextxy(getmaxx()-4 -textwidth(author), getmaxy()-20, author);<br /> setcolor(GREEN);<br /> setbkcolor(BLACK);<br /><br /> int x0, y0, x1, y1;<br /> MYCOLOR = WHITE;<br /> std::cout << "Enter \'-400\' to exit\n";<br /> std::cout << "Enter the coordinates of end points: [x0 y0 x1 y1]\n";<br /><br /> std::cin >> x0;<br /> while(x0 != -400) {<br /> std::cin >> y0 >> x1 >> y1;<br /> sprintf(point, "(%4d, %4d)", x0, y0);<br /> outtextxy(320+x0-textwidth(point)/2, 240-y0+2, point);<br /> sprintf(point, "(%4d, %4d)", x1, y1);<br /> outtextxy(320+x1-textwidth(point)/2, 240-y1+2, point);<br /> drawLine(x0, y0, x1, y1);<br /><br /> setcolor(WHITE);<br /> setbkcolor(GREEN);<br /> outtextxy(320 - textwidth(algo)/2, 5, algo);<br /> outtextxy(getmaxx()-4 -textwidth(author), getmaxy()-20, author);<br /> setcolor(GREEN);<br /> setbkcolor(BLACK);<br /><br /> std::cin >> x0;<br /> }<br /><br /> closegraph();<br /> return 0;<br />}<br /><br /></code></pre>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com0tag:blogger.com,1999:blog-4276715425787171951.post-84855683171201624072009-09-08T19:05:00.008+05:302009-09-08T20:22:32.982+05:30Digital Differential Analyzer (DDA) Algorithm<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_4Mr9PcctaeY/SqZhVEE26oI/AAAAAAAAACg/U_UUfn8mFDk/s1600-h/DDA_01.png"><img style="cursor: pointer; width: 400px; height: 300px;" src="http://3.bp.blogspot.com/_4Mr9PcctaeY/SqZhVEE26oI/AAAAAAAAACg/U_UUfn8mFDk/s400/DDA_01.png" alt="" id="BLOGGER_PHOTO_ID_5379093819439901314" border="0" /></a><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_4Mr9PcctaeY/SqZhUqfyBNI/AAAAAAAAACY/eZSSKxVVo-0/s1600-h/DDA_02.png"><img style="cursor: pointer; width: 400px; height: 300px;" src="http://1.bp.blogspot.com/_4Mr9PcctaeY/SqZhUqfyBNI/AAAAAAAAACY/eZSSKxVVo-0/s400/DDA_02.png" alt="" id="BLOGGER_PHOTO_ID_5379093812573504722" border="0" /></a><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_4Mr9PcctaeY/SqZhUc95oyI/AAAAAAAAACQ/XBFMC4gcPhs/s1600-h/DDA_03.png"><img style="cursor: pointer; width: 398px; height: 459px;" src="http://3.bp.blogspot.com/_4Mr9PcctaeY/SqZhUc95oyI/AAAAAAAAACQ/XBFMC4gcPhs/s400/DDA_03.png" alt="" id="BLOGGER_PHOTO_ID_5379093808941736738" border="0" /></a><br /><br /><pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"><code>/*************************************************<br />* Digital Differential Analyzer (DDA) Algorithm *<br />*************************************************<br />* Usage :- Simple and general method for rasterizing lines and triangles<br />* Author :- Rooparam Choudhary<br />* Date :- August 29, 2009<br />* Place :- Shri Mata Vaishno Devi University<br />* EntryNo :- 2006ECS20<br />*/<br /><br />#include <graphics.h><br />#include <stdlib.h><br />#include <stdio.h><br />#include <iostream><br /><br />#define ROUND(x) ((int)(x+0.5))<br /><br />int MYCOLOR = WHITE;<br /><br />inline void setpixel(int, int);<br />void DDA(int, int, int, int);<br />void unionJack(void);<br />void hexagon(int, int);<br />void randomUnionJack(int);<br /><br />inline void setpixel(int x, int y){<br /> putpixel(320+x, 240-y, MYCOLOR);<br />}<br /><br />void randomUnionJack(int count){<br /> void DJ(int, int, int);<br /> int xr, yr, clr=0;<br /> srand(time(NULL));<br /> <br /> while(count-- > 0){<br /> xr = -320 + rand()%641;<br /> yr = -240 + rand()%481;<br /> clr = 0;<br /> if(yr > -xr){<br /> if(xr < 0) clr = 3;<br /> else if(yr < 0) clr = 2;<br /> else if(yr > xr) clr = 4;<br /> else if(yr < xr) clr = 1;<br /> }else if(yr < -xr) {<br /> if(xr > 0) clr = 3;<br /> else if(yr > 0) clr = 2;<br /> else if(yr < xr) clr = 4;<br /> else if(yr > xr) clr = 1;<br /> }<br /> DJ(xr, yr, clr);<br /> }<br />}<br /><br />void DJ(int x, int y, int clr){<br /> int shade = 0;<br /> switch(clr){<br /> case 1: shade = RED; break;<br /> case 2: shade = BLUE; break;<br /> case 3: shade = CYAN; break;<br /> case 4: shade = MAGENTA; break;<br /> default: return; break;<br /> }<br /> putpixel(320+x, 240-y, shade);<br />}<br /><br />void DDA(int x0, int y0, int x1, int y1) {<br /> int delX = x1-x0, delY = y1-y0, steps, k;<br /> float x=x0, y=y0, incX, incY;<br /><br /> steps = (abs(delX) > abs(delY)) ? abs(delX) : abs(delY) ;<br /><br /> incX = delX / (float)steps;<br /> incY = delY / (float)steps;<br /><br /> setpixel(ROUND(x), ROUND(y));<br /> for(k=0; k<steps; ++k) {<br /> x += incX;<br /> y += incY;<br /> setpixel(ROUND(x), ROUND(y));<br /> }<br />}<br /><br />int main(void) {<br /> int gd = DETECT, gm;<br /> char *author = "Coder:- Rooparam Choudhary";<br /> char *algo = "Digital Differential Analyzer Algorithm";<br /> char point[30];<br /> std::cout << "Digital Differential Analyzer Algorithm\n";<br /> std::cout << author << std::endl;<br /> initgraph(&gd, &gm, "C:\\");<br /><br /> setcolor(WHITE);<br /> setbkcolor(GREEN);<br /> outtextxy(320 - textwidth(algo)/2, 5, algo);<br /> outtextxy(getmaxx()-4 -textwidth(author), getmaxy()-20, author);<br /> setcolor(GREEN);<br /> setbkcolor(BLACK);<br /><br /> MYCOLOR = GREEN;<br /> // X-axis<br /> DDA(-320, -1, 320, -1);<br /> DDA(-320, 0, 320, 0);<br /> DDA(-320, 1, 320, 1);<br /> // Y-axis<br /> DDA(-1, 240, -1, -240);<br /> DDA( 0, 240, 0, -240);<br /> DDA( 1, 240, 1, -240);<br /> // Y - X = 0<br /> DDA(-240, -240, 240, 240);<br /> // Y + X = 0<br /> DDA(-240, 240, 240, -240);<br /><br /> MYCOLOR = BROWN;<br /> hexagon(-160, 120);<br /> hexagon(160, 120);<br /> hexagon(160, -120);<br /> hexagon(-160, -120);<br /><br /> std::cout << "Enter samples for union jack\n(SHOULD BE GEATER THAN 100K): ";<br /> int samp;<br /> std::cin >> samp;<br /> //unionJack();<br /> randomUnionJack(samp);<br /><br /> setcolor(WHITE);<br /> setbkcolor(GREEN);<br /> outtextxy(320 - textwidth(algo)/2, 5, algo);<br /> outtextxy(getmaxx()-4 -textwidth(author), getmaxy()-20, author);<br /> setcolor(GREEN);<br /> setbkcolor(BLACK);<br /><br /> int x0, y0, x1, y1;<br /> MYCOLOR = WHITE;<br /> std::cout << "Enter \'-400\' to exit\n";<br /> std::cout << "Enter the coordinates of end points: [x0 y0 x1 y1]\n";<br /><br /> std::cin >> x0;<br /> while(x0 != -400) {<br /> std::cin >> y0 >> x1 >> y1;<br /> sprintf(point, "(%4d, %4d)", x0, y0);<br /> outtextxy(320+x0-textwidth(point)/2, 240-y0+2, point);<br /> sprintf(point, "(%4d, %4d)", x1, y1);<br /> outtextxy(320+x1-textwidth(point)/2, 240-y1+2, point);<br /> DDA(x0, y0, x1, y1);<br /><br /> setcolor(WHITE);<br /> setbkcolor(GREEN);<br /> outtextxy(320 - textwidth(algo)/2, 5, algo);<br /> outtextxy(getmaxx()-4 -textwidth(author), getmaxy()-20, author);<br /> setcolor(GREEN);<br /> setbkcolor(BLACK);<br /><br /> std::cin >> x0;<br /> }<br /><br /> closegraph();<br /> return 0;<br />}<br /><br />void unionJack(void){<br /> for(int y = 240; y>0; --y) {<br /> int x = -321;<br /><br /> MYCOLOR = BLUE;<br /> while(++x < -y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = CYAN;<br /> while(++x < 0)<br /> { putpixel(320+x, 240-y, MYCOLOR); } <br /> MYCOLOR = MAGENTA;<br /> while(++x < y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = RED;<br /> while(++x < 321)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> }<br /> for(int y = -1; y>-241; --y) {<br /> int x = -321;<br /><br /> MYCOLOR = RED;<br /> while(++x < y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = MAGENTA;<br /> while(++x < 0)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = CYAN;<br /> while(++x < -y)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> MYCOLOR = BLUE;<br /> while(++x < 321)<br /> { putpixel(320+x, 240-y, MYCOLOR); }<br /> }<br />}<br /><br />void hexagon(int xc, int yc) {<br /> DDA(xc+60, yc+104, xc+120, yc);<br /> DDA(xc+60, yc+104, xc+60, yc-104);<br /> DDA(xc+60, yc+104, xc-60, yc-104);<br /> DDA(xc+60, yc+104, xc-120, yc);<br /> DDA(xc+60, yc+104, xc-60, yc+104);<br /> DDA(xc+120, yc, xc+60, yc-104);<br /> DDA(xc+120, yc, xc-60, yc-104);<br /> DDA(xc+120, yc, xc-120, yc);<br /> DDA(xc+120, yc, xc-60, yc+104);<br /> DDA(xc+60, yc-104, xc-60, yc-104);<br /> DDA(xc+60, yc-104, xc-120, yc);<br /> DDA(xc+60, yc-104, xc-60, yc+104);<br /> DDA(xc-60, yc-104, xc-120, yc);<br /> DDA(xc-60, yc-104, xc-60, yc+104);<br /> DDA(xc-120, yc, xc-60, yc+104);<br />}<br /><br /></code></pre>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com0tag:blogger.com,1999:blog-4276715425787171951.post-38802219065031593122009-06-21T05:29:00.004+05:302009-09-08T20:26:09.415+05:30logic behind long division square root algorithm<p>Let's say we are to find the square root of <i>a</i>. The algorithm is finding one more digit to the square root at each 'go'. That means it is approaching the actual value of the square root from below, or that at each step the approximation is always less than or equal to the actual value of the square root. If <i>x</i> is the approximation found this far, at each go, one wants to find a better approximation <i>x</i> + <i>r</i> so that <i>x</i> + <i>r </i>≤ √<span style="text-decoration: overline;"><i>a</i></span>. From this inequality follows:</p> <div align="center"> <table border="0" cellpadding="2" cellspacing="0"> <tbody><tr> <td> <p align="right"> <i>x</i> + <i>r</i> </p></td> <td> ≤ </td> <td> <p> √<span style="text-decoration: overline;"><i>a</i></span></p> </td> </tr> <tr> <td> <p align="right">(<i>x</i> + <i>r</i>)<sup>2</sup> </p></td> <td> ≤</td> <td> <p><i>a</i></p> </td> </tr> <tr> <td> <p align="right"><i>x</i><sup>2</sup> + 2<i>xr</i> + <i>r</i><sup>2</sup> </p></td> <td> ≤</td> <td><i>a</i> </td> </tr> <tr> <td><i>x</i><sup>2</sup> + (2<i>x</i> + <i>r</i>) <i>r</i></td> <td> ≤</td> <td><i>a</i></td> </tr> <tr> <td> <p align="right">(2<i>x</i> + <i>r</i>) <i>r</i></p></td> <td> ≤</td> <td align="center"><i>a</i> − <i>x</i><sup>2</sup></td> </tr> </tbody></table> </div> <p>and the last line corresponds to the step where the user tries different values of <i>r</i> on that empty line so that 2<i>x</i> and <i>something</i> times <i>something </i>is less than the subtraction result.<br /></p>rooparamhttp://www.blogger.com/profile/12550457138663790550noreply@blogger.com2