286 lines
5.1 KiB
HTML
286 lines
5.1 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Just For Fun !!!</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
|
|
REL="HOME"
|
|
TITLE=" NCURSES Programming HOWTO "
|
|
HREF="index.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE=" Tools and Widget Libraries"
|
|
HREF="tools.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="References"
|
|
HREF="ref.html"></HEAD
|
|
><BODY
|
|
CLASS="SECT1"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
SUMMARY="Header navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>NCURSES Programming HOWTO</TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="tools.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
></TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="ref.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="SECT1"
|
|
><H1
|
|
CLASS="SECT1"
|
|
><A
|
|
NAME="JUSTFORFUN"
|
|
></A
|
|
>20. Just For Fun !!!</H1
|
|
><P
|
|
>This section contains few programs written by me just for fun. They don't
|
|
signify a better programming practice or the best way of using ncurses. They are
|
|
provided here so as to allow beginners to get ideas and add more programs to
|
|
this section. If you have written a couple of nice, simple programs in curses
|
|
and want them to included here, contact <A
|
|
HREF="mailto:ppadala@gmail.com"
|
|
TARGET="_top"
|
|
>me</A
|
|
>.</P
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="GAMEOFLIFE"
|
|
></A
|
|
>20.1. The Game of Life</H2
|
|
><P
|
|
>Game of life is a wonder of math. In
|
|
<A
|
|
HREF="http://www.math.com/students/wonders/life/life.html"
|
|
TARGET="_top"
|
|
>Paul Callahan</A
|
|
>'s words</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="PROGRAMLISTING"
|
|
><EM
|
|
>The Game of Life (or simply Life) is not a game in the conventional sense. There
|
|
are no players, and no winning or losing. Once the "pieces" are placed in the
|
|
starting position, the rules determine everything that happens later.
|
|
Nevertheless, Life is full of surprises! In most cases, it is impossible to look
|
|
at a starting position (or pattern) and see what will happen in the future. The
|
|
only way to find out is to follow the rules of the game.</EM
|
|
></PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
>This program starts with a simple inverted U pattern and shows how wonderful
|
|
life works. There is a lot of room for improvement in the program. You can let
|
|
the user enter pattern of his choice or even take input from a file. You can
|
|
also change rules and play with a lot of variations. Search on <A
|
|
HREF="http://www.google.com"
|
|
TARGET="_top"
|
|
>google</A
|
|
> for interesting information on game
|
|
of life.</P
|
|
><P
|
|
><EM
|
|
>File Path: JustForFun/life.c</EM
|
|
></P
|
|
></DIV
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="MAGIC"
|
|
></A
|
|
>20.2. Magic Square</H2
|
|
><P
|
|
>Magic Square, another wonder of math, is very simple to understand but very
|
|
difficult to make. In a magic square sum of the numbers in each row, each column
|
|
is equal. Even diagnol sum can be equal. There are many variations which have
|
|
special properties.</P
|
|
><P
|
|
>This program creates a simple magic square of odd order.</P
|
|
><P
|
|
><EM
|
|
>File Path: JustForFun/magic.c</EM
|
|
></P
|
|
></DIV
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="HANOI"
|
|
></A
|
|
>20.3. Towers of Hanoi</H2
|
|
><P
|
|
>The famous towers of hanoi solver. The aim of the game is to move the disks on
|
|
the first peg to last peg, using middle peg as a temporary stay. The catch is
|
|
not to place a larger disk over a small disk at any time.</P
|
|
><P
|
|
><EM
|
|
>File Path: JustForFun/hanoi.c</EM
|
|
></P
|
|
></DIV
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="QUEENS"
|
|
></A
|
|
>20.4. Queens Puzzle</H2
|
|
><P
|
|
>The objective of the famous N-Queen puzzle is to put N queens on a N X N chess
|
|
board without attacking each other. </P
|
|
><P
|
|
>This program solves it with a simple backtracking technique.</P
|
|
><P
|
|
><EM
|
|
>File Path: JustForFun/queens.c</EM
|
|
></P
|
|
></DIV
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="SHUFFLE"
|
|
></A
|
|
>20.5. Shuffle</H2
|
|
><P
|
|
>A fun game, if you have time to kill. </P
|
|
><P
|
|
><EM
|
|
>File Path: JustForFun/shuffle.c</EM
|
|
></P
|
|
></DIV
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="TT"
|
|
></A
|
|
>20.6. Typing Tutor</H2
|
|
><P
|
|
>A simple typing tutor, I created more out of need than for ease of use. If you
|
|
know how to put your fingers correctly on the keyboard, but lack practice, this
|
|
can be helpful. </P
|
|
><P
|
|
><EM
|
|
>File Path: JustForFun/tt.c</EM
|
|
></P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
SUMMARY="Footer navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="tools.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
ACCESSKEY="H"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="ref.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>Tools and Widget Libraries</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
> </TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>References</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |