Messages - h0meopathic [ switch to compact view ]

Pages: prev1 2 3 4 [5]
21
Developer's Corner / Re: C# Palindrom Recursive Program
« on: April 19, 2007, 03:43 PM »
This is the Palindrom in non recursive format but I need to put it in recursive format. From my understanding I should put most of this code in a method, probably in another class, then have the main method call upon it every time the system loops
==========================================================
Code: C# [Select]
  1. namespace RecursivePalindromeTester
  2. {
  3.     class Palindrome
  4.     {
  5.         String str, another = "y";
  6.             int left, right;
  7.  
  8.             while (another.ToUpper() == "Y")
  9.             {
  10.                 Console.Out.WriteLine("Enter a potential Palindrome:");
  11.                 str = Console.In.ReadLine();
  12.  
  13.                 left = 0;
  14.                 right = str.Length - 1;
  15.  
  16.                 while (str[left] == str[right] && left < right)
  17.                 {
  18.                     left++;
  19.                     right--;
  20.                 }
  21.  
  22.                 Console.Out.WriteLine();
  23.  
  24.                 if (left < right)
  25.                     Console.Out.WriteLine("String is Not a Palindrome.");
  26.                 else
  27.                     Console.Out.WriteLine("String is a Palindrome.");
  28.                
  29.                 Console.Out.WriteLine();
  30.                 Console.Out.Write("Test another PalindromTester (Y/N)? ");
  31.                 another = Console.In.ReadLine();      
  32.     }
  33. }

22
Developer's Corner / C# Palindrom Recursive Program
« on: April 17, 2007, 09:38 PM »
I have to make a program using C# that makes a PalindromeTester using Recursive methods. I can make the program using normal methods i.e. while statements and nested if statements. I can't figure it out even after doing a lot of research and while looking at sudocode from someone writing it in java. Could someone help. I don't necessarily want someone to do the work for me but help me think it through using the c# language. I would talk to my Teacher about it but she can't bring herself to coming to my level. People with Ph.D's shouldn't be allowed to teach low level college classes. 

Pages: prev1 2 3 4 [5]
Go to full version