| Schultz's profileSchultzpacePhotosBlogNetwork | Help |
SchultzpaceUploaded |
May 02 Tower of Hanoi in C#using System; using System.Collections.Generic; using System.Text;
namespace Hanoi { class Program { static void Main(string[] args) { int count = 3; if (args.Length != 0 && !Int32.TryParse(args[0], out count)) { count = 3; }
for (int i = 0; i < 3; i++) { pinsAndDisks[i] = new Stack<int>(); }
for (int i = 0; i < count; i++) { pinsAndDisks[0].Push(count - i); }
Hanoi(0, 2, 1, count);
Console.WriteLine("Total number of calls: {0}.", depth); }
static int depth; static Stack<int>[] pinsAndDisks = new Stack<int>[3];
static void Hanoi(int source, int dest, int misc, int count) { depth++;
if (count == 1) { MoveAndPrint(source, dest); } else { Hanoi(source, misc, dest, count - 1); MoveAndPrint(source, dest); Hanoi(misc, dest, source, count - 1); } }
static void MoveAndPrint(int source, int dest) { int disk = pinsAndDisks[source].Pop(); pinsAndDisks[dest].Push(disk); for (int pin = 0; pin < 3; pin++) { if (pinsAndDisks[pin].Count == 0) { Console.WriteLine("|-----"); } else { string pinView = ""; Stack<int>.Enumerator e = pinsAndDisks[pin].GetEnumerator(); while (e.MoveNext()) { pinView = e.Current + "-" + pinView; } Console.WriteLine("|-" + pinView); } } Console.WriteLine(); } } }
September 20 Iniana state PI redifinition: "Establishing scientific truth by legislative fiat.""The Indiana Pi Bill is the popular name for bill #246 of the 1897 sitting of the Indiana General Assembly, which is one of the most famous historical attempts to establish scientific truth by legislative fiat. Despite its popular name, the main result claimed by the bill is a method to square the circle, rather than the establishment of the value of π. Nevertheless, the bill does contain text which appears to dictate varying wrong values of π such as 3.2. Note that the impossibility of squaring the circle (using only compass and straightedge), suspected since ancient times, was first rigorously proved in 1882 by von Lindemann, and better approximations of π have been known since ancient times."
September 11 Michael Schumacher - the end of an era... Sad.After 90 wins, 1354 points and seven world championship titles, Michael Schumacher has announced he will retire at the end of this season. Statistically the greatest driver the sport has ever seen, Schumacher has, over the past 16 years, set a new standard to which younger drivers can only aspire. He may have courted controversy at times, but with his departure, the sport will lose one of its leading lights.
See for more here: http://www.formula1.com/race/news/4932/765.html July 17 Using CoInitializeExNot really obvious but if you included all headers and still are getting a compiler error
then it means you simply need to define _WIN32_DCOM. FREE Antivirus. avast! 4 Home Edition. Stop the crap!http://www.avast.com/eng/avast_4_home.html
"avast! 4 Home Edition is a full-featured antivirus package designed exclusively for home users and non-commercial use. Both of these conditions should be met! Our company offers the Home Edition free of charge, since, in our opinion, it is possible to avoid global virus spreading by efficient prevention; however, many user are not able to or do not want to pay for antivirus software. This page will show you the most important features of this program." |
||||
|
|