Providers
Debian Linux
SDF
MinGW-W64
Verizon
Research
Search Engines
Bing
DuckDuckGo
Google
Metacrawler
SearX
Miscellaneous
Faqs and RFCs
Open Directory Project
W3Schools Online Web Tutorials
Wikipedia
Multimedia
CTIS
For the Pigs Among Us
Family Photos
My House
My Photos (1999-2002?)
My Photos (2005)
Retro Computers
Minions of Mirth
Main
Criticals
Criticals (Single Player)
Ghaqua
Maps and Points of Interest
Miscellaneous
Monster Templates
Miscellaneous
Area Codes
Bard’s Tale
Dungeons & Dragons Online
My Blog
Quote of the Day
RogueBasin
Slashdot
The Adventuer’s Guild
Weather
GitHub:eprive/Z80-MBC3
Programming
Main
Across
Biorhythm
BMP Chips
Complex Roots
Magic Square
Magic Square(js)
Matrix(js)
More DOS Programs
Roll
Strip Dups (bash)
Wacky Wood-Worker
How To
Enlightenment 0.16.7.2 Startup Patch
How to Create an OS X Iconset
My RedHat Howto
SSH to VMS (Deathrow OpenVMS Cluster)
Tools
Allowable Mortgage Interest
Dates and Mileage
Day of the Year
Fun With Time
Downloads
Educational
Utilities
magicsquare.cpp
// magicSquare.cpp Michael J. Chappell 23 January 2010 // version 2.0 21 October 2017 // version 2.1 22 February 2020 // version 2.2 05 December 2022 // version 2.3 08 December 2022 // version 2.4 09 June 2024 // Implementation of Magic Squares from Merlin #include <iostream> using namespace std; #include <curses.h> #include <cstdlib> #if defined(__NetBSD__) || defined(__linux__) #include <unistd.h> #endif #include "magicsquare.h" int toggle[] = {0, TOG1, TOG2, TOG3, TOG4, TOG5, TOG6, TOG7, TOG8, TOG9}; int main(int argc, char **argv) { int board = 0; int again = 1; int t = 0; int count = 0; #if defined(__APPLE__) srandomdev(); #elif defined(__NetBSD__) || defined(__linux__) srandom(getpid()); #else srandom(clock()); #endif initscr(); cbreak(); noecho(); curs_set(0); while(again) { board = init(argc, argv); showboard(board); count = 0; do { t = getnum(9); if (!t) { break; } else { board ^= toggle[t]; showboard(board); count++; } } while (board != WINNER); if (board == WINNER) { winner(count); } else { quitter(); } playagain(); again = getnum(1); } curs_set(1); echo(); endwin(); } // main int init(int argc, char **argv) { int q = 0; q = ((random()%511)+WINNER+1)%511; return q; }
This source has been viewed 24 times.
Friday, 18 April 2025
Michael J. Chappell
Contact me at:
mcsuper5@freeshell.org