2. Fibonacci series, swapping two variables, finding maximum/minimum among a list of numbers. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace lrn2Csharp2 { class Program { static void Main( string[ ] args ) { int fibs = 21; int[ ] fib_series = new int[ fibs ]; Console.WriteLine( "Outputing Fib 0 through " + fibs ); for ( int i = 0; i < fib_series.Length; i++ ) { fib_series[ i ] = fibonacci( i ); } printArray( fib_series ); Console.WriteLine( "" ); Console.WriteLine( "Max in Fib Series: " + max( fib_series ) ); Console.WriteLine( "Min in Fib Series: " + min( fib_series ) ); Console.WriteLine( "Swapping front with end: " ); swap<int>( ref fib_series[ 0 ], ref fib_series[ fib_series.Length - 1 ] ); printArray( fib_series ); Console.WriteLine( "" ); Console.WriteLine( "Press esc to exit." ); while ( !keyPressHandler( Console.ReadKey( true ) ) ) { Thread.Sleep( 250 ); /* no op */ } } static void swap<T>( ref T lhs, ref T rhs ) { T temp; temp = lhs; lhs = rhs; rhs = temp; } public static int fibonacci( int n ) { if ( n <= 1 ) { return n; } else { return fibonacci( n - 1 ) + fibonacci( n - 2 ); } } public static int max( int[ ] n ) { int max = n[ 0 ]; for ( int _i = 0; _i < n.Length; _i++ ) { if ( n[ _i ] > max ) max = n[ _i ]; } return max; } public static int min( int[ ] n ) { int min = n[ 0 ]; for ( int _i = 0; _i < n.Length; _i++ ) { if ( n[ _i ] < min ) min = n[ _i ]; } return min; } public static void printArray( int[ ] n ) { for ( int _i = 0; _i < n.Length; _i++ ) { Console.Write( n[ _i ] + " " ); } } protected static Boolean keyPressHandler( ConsoleKeyInfo input ) { if ( input.Key == ConsoleKey.Escape ) return true; return false; } } }

posted by dharh 12:47 AM Nov 29th, 2009

It's been a while since I've made an actual post, but I felt the urge. I do alot of programming (many different languages), so after I read this interview I thought i'd share it.

posted by dharh 1:05 PM Aug 7th, 2009

Looks like the twitter integration has worked pretty well.

posted by dharh 3:46 PM May 27th, 2009

Yes I'm still around. I got lazy and busy at the same time, so no updates since the last one till now. I was bored and have nothing to do till christmas stuff starts tomorrow so I started messing around on the web. Read an article "Twitter, Flickr, Facebook Make Blogs Look So 2004" aka "The Blog is Dead". And so it is! Though not for the reasons the article explains, mine is dead right now... well... I already mentioned that. Anyway, I made a twitter account and hopefully January I will force myself to add my twitter feed to my feed eater here at IDT.

Don't hold your breath though. I wouldn't want any blood on my hands.


posted by dharh 6:32 PM Dec 24th, 2008


posted by dharh 9:01 AM May 13th, 2008

I've moved the site over to a new host. LFC Hosting. I've been using them a while for other stuff and have been happy with them. There will be a few issues here and there, but I'll get the kinks worked out soon.

posted by dharh 6:33 PM Apr 9th, 2008



« Previous 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Next »

2024: 11 1
2023: 4 2 1
2022: 5 3
2011: 5 3 1
2010: 12 9 7 1
2009: 12 11 8 5
2008: 12 5 4 3 2 1
2007: 12 11 10 9 8 7 6 5 4 3 2 1
2006: 12 11 10 9 8 7 6 5 4 3 2 1
2005: 12 10 7 6
2004: 10 9 6 5 4 3 2 1