static void Main(string[] args) { bool isPalindrome; Palindrome palindrome = new Palindrome(); string line; //https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/file-system/how-to-read-a-text-file-one-line-at-a-time // Read the file and display it line by line. System.IO.StreamReader file = new System.IO.StreamReader(@"E:\Downloads\Uni\palindromes.txt"); while ((line = file.ReadLine()) != null) { isPalindrome = palindrome.FillStackQueue(line); if (isPalindrome) { Console.WriteLine(line + " is a palindrome!"); } else { Console.WriteLine(line + " is not a palindrome!"); } } file.Close(); }
public void ShouldTestPalindromeClass() { _output.WriteLine("Başla"); var list = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("kjjjhjjj", "k"), new KeyValuePair <string, string>("abcacba", _palindrome), //mid trim new KeyValuePair <string, string>("abxyba", "xy"), //mid trim new KeyValuePair <string, string>("abxxcba", "xx"), //mid trim new KeyValuePair <string, string>("abcxxba", "cx"), //mid trim new KeyValuePair <string, string>("kkjjjhjjj", "kk"), //head trim new KeyValuePair <string, string>("kjjjhjjj", "k"), //head trim new KeyValuePair <string, string>("jjjhjjjss", "ss"), //back trim new KeyValuePair <string, string>("jjjhjjjs", "s"), //back trim new KeyValuePair <string, string>("mmop", _notPossible), //mix }; var isItClear = true; foreach (var item in list) { var palindrome = new Palindrome(item.Key, 2); var result = palindrome.GetResult(); _output.WriteLine($"Değer: {item.Key}, beklenen: {item.Value}, sonuç: {result}"); if (isItClear) { isItClear = item.Value == result; } } Assert.True(isItClear); }
static void Main(string[] args) { Console.WriteLine("Welcome to palindrome tester.\n"); var palindrome = new Palindrome(); while (true) { Console.Write("Enter a word or phrase: "); var input = Console.ReadLine(); if (String.IsNullOrEmpty(input)) { break; } var message = palindrome.IsValid(input) ? Valid : Invalid; Console.WriteLine(message); } Console.ReadKey(); }
private void btnCheck_Click(object sender, EventArgs e) { Palindrome palindrome = new Palindrome(); palindrome.UserInput = tbUserInput.Text; MessageBox.Show(palindrome.CheckPalindrome()); }
static void Main(string[] args) { Console.Write("Enter text to see if its a palindrome:"); string userinput = Console.ReadLine(); Palindrome Pal = new Palindrome(); try { Console.WriteLine(Pal.IsPalindrone(userinput)); } catch { Console.WriteLine("There has been an Error"); } do { Console.WriteLine("Try Again or Exit"); userinput = Console.ReadLine(); if (userinput == "exit") { break; } Console.WriteLine(Pal.IsPalindrone(userinput)); } while (userinput != "exit"); }
static void Main(string[] args) { string EnterWord = string.Empty; string Exit = string.Empty; string EnterWordReversed = string.Empty; do { try { Console.Write("Enter text to see if it’s a palindrome "); EnterWord = Console.ReadLine(); Palindrome Paldrm = new Palindrome(); EnterWordReversed = Paldrm.GetText(EnterWord); if (Paldrm.IsPalindrome(EnterWord, EnterWordReversed) == true) { Console.WriteLine("Its A Palindrome"); } else { Console.WriteLine("Its Not A Palindrome"); } } catch (Exception ex) { Console.WriteLine("An Error Occurred"); } Console.WriteLine(" If you want to Exit type N"); Exit = Console.ReadLine(); } while (Exit != "N"); }
static void Main(string[] args) { string userExitYn = ""; string userPalinValue = ""; string userPalinValueRvrs = ""; do { Console.Write("Welcome to the Palindrome Program: Type 'Y' to continue, or 'N' to exit: "); userExitYn = Console.ReadLine(); if (userExitYn == "Y") { try { Console.Write("Enter text to see if it’s a palindrome: "); userPalinValue = Console.ReadLine(); /* Checks the user input to make sure it's of an acceptable * character length*/ if ((userPalinValue.Length >= 26) || (userPalinValue.Length < 1)) { /* Error handling for missing input or input that's too long */ Console.WriteLine("Must input 1 to 25 characters"); throw new Exception(); } /* Creates a new instance of the Palindrome class */ Palindrome clPalin = new Palindrome(); /* Calls the string method in the Palindrome class to reverse the user input string */ userPalinValueRvrs = clPalin.GetRvrsString(userPalinValue); /* Calls the boolean method in the Palindrome class to compare the user input string * with the user input string in reverse. Based on if the strings match, a message * is displayed to the user indicating if their input is a palindrome. */ if (clPalin.IsPalindrome(userPalinValue, userPalinValueRvrs) == true) { Console.Write($"{userPalinValue} is a Palindrome"); Console.WriteLine(""); Console.WriteLine(""); continue; } else { Console.Write($"{userPalinValue} is not a Palindrome"); Console.WriteLine(""); Console.WriteLine(""); continue; } } catch (Exception ex) { Console.WriteLine("An error has occurred. Start over below."); Console.WriteLine(""); } } } while (userExitYn != "N"); }
public static void Main(string[] args) { string msg = ""; try { do { Console.Write("Is it a Palindrome? Enter your text to find out now! "); msg = Console.ReadLine(); if (msg.Length >= 50) { throw new OverflowException(); } //char[] chArray = msg.ToCharArray(); Palindrome myPal = new Palindrome(); myPal.IsPalindrome(msg); Console.WriteLine(""); Console.ReadLine(); } while (msg.ToUpper() != "EXIT"); } catch (OverflowException) { Console.WriteLine("There is a maximum character length of 50."); } }
static void Main(string[] args) { Palindrome num = new Palindrome(); Console.Write("Enter your number : "); num.Number = Convert.ToInt32(Console.ReadLine()); num.getResult(); }
static void Main(string[] args) { Console.WriteLine("Podaj tekst: "); var input = Console.ReadLine(); var checker = new Palindrome(); checker.IsPalindrome(input); }
static void Main(string[] args) { Console.Write("input string: "); var str = Console.ReadLine(); Palindrome palindrome = new Palindrome(); Console.WriteLine($"{str}: {(palindrome.checkIsPalindrome(str) ? "是回文" : "不是回文")}"); }
public static void Main(string[] args) { Console.WriteLine(Palindrome.IsPalindrome("eaae")); Console.WriteLine(Palindrome.IsPalindrome("Deleveled")); Console.WriteLine(Palindrome.IsPalindrome("KAYAK")); Console.WriteLine(Palindrome.IsPalindrome("Never a foot too far, even.")); Console.ReadKey(); }
static void Main(string[] args) { string checkString = "@alula 7689679"; string ans = Palindrome.isPalindrome(checkString); Console.WriteLine(ans); Console.ReadKey(); }
static void Main(string[] args) { string[] values = { "Deleveled", "Neuquen", "C sharp" }; foreach (string value in values) { Console.WriteLine(String.Format("{0} is {1}a palindrome.", value, Palindrome.IsPalindrome(value)? String.Empty : "not ")); } }
static void Main(string[] args) { Palindrome current = new Palindrome(); current.ExecutePalindrome(); Console.WriteLine("END OF PROGRAM"); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Enter a string that is a potential palindrome: "); var input = Console.ReadLine(); Console.WriteLine(Palindrome.IsPalindrome(input) ? "Your string was a palindrome!" : "Your string was not a palindrome."); Console.ReadLine(); }
static void Main(string[] args) { string finchaine; string Phrase; string Palindrome; do { Console.WriteLine("Veuillez saisir une phrase terminée par un point(.)..."); Phrase = Console.ReadLine().ToLower(); finchaine = Phrase.Substring(Phrase.Length - 1, 1); } while (finchaine != "."); if (Phrase.Length == 1 && finchaine == ".") { Console.WriteLine("La chaine est vide !!"); } else { Palindrome = Phrase.Substring(0, Phrase.Length - 1); Palindrome = Palindrome.Replace(" ", string.Empty); char[] endroit = Palindrome.ToCharArray(); char[] envers = new char[Palindrome.Length]; //remplissage du tableau envers for (int i = 0; i < endroit.Length; i++) { envers[i] = endroit[(endroit.Length - 1) - i]; } //recherche de palindrome bool verif = true; for (int i = 0; i < Palindrome.Length; i++) { if (endroit[i] != envers[i]) { verif = false; break; } } if (verif == true) { Console.WriteLine("la phrase est un palindrome"); } else { Console.WriteLine("la phrase n'est pas un palindrome"); } AfficherTab(endroit); AfficherTab(envers); } }
static void Main(string[] args) { Palindrome p = new Palindrome(); Console.WriteLine(p.IsPalindrome("ABCdef")); Console.WriteLine(p.IsPalindrome("Noon")); Console.WriteLine(p.IsPalindrome("racecar")); Console.WriteLine(p.IsPalindrome("hello")); Console.WriteLine(p.IsPalindrome("pneumonoultramicroscopicsilicovolcanoconiosi")); Console.WriteLine(p.IsPalindrome("tatTARrattat")); }
static void Main(string[] args) { Console.WriteLine("Type a word to see if it is a palindrome:"); string input = Console.ReadLine(); Palindrome palindrome = new Palindrome(); Console.WriteLine(palindrome.IsWordAPalindrome(input)); Console.ReadLine(); }
static void Main(string[] args) { BasicConfigurator.Configure(); Palindrome program = new Palindrome(); String inputString = "do geese see god"; String inputString2 = "go hang a salami im a lasagna hog"; Boolean isPalindrome1 = program.isPalindrome(inputString); Boolean isPalindrome2 = program.isPalindrome(inputString2); Boolean isPalindrome3 = program.isPalindrome("sjhfj"); Console.WriteLine(isPalindrome1); Console.WriteLine(isPalindrome2); Console.WriteLine(isPalindrome3); }
static void Main() { Console.WriteLine("Enter your word to see if it is a Palindrome:"); string userWord = Console.ReadLine(); Palindrome newPal = new Palindrome(); if (newPal.IsPalindrome(userWord)) { Console.WriteLine("Your word is a Palindrome!"); } else { Console.WriteLine("Your word is not a Palindrome."); } }
static void Main(string[] args) { Console.Write("Por favor digite a palavra: "); var word = Console.ReadLine().ToLower(); var result = Palindrome.IsPalindrome(word); if (result == true) { Console.WriteLine("A palavra é um Palindrome!"); } else { Console.WriteLine("Não é um Palindrome!"); } }
static void Main(string[] args) { Palindrome p = new Palindrome(); p.value = "malayalam"; if (p.CheckPalindrome(p.value)) { Console.WriteLine("{0} is a Palindrome", p.value); } else { Console.WriteLine("{0} is not a Palindrome", p.value); } Console.Read(); }
static void Main(string[] args) { string userInput; bool result; try { Console.Write("Input a word to test if its a palindrome: "); userInput = Console.ReadLine(); result = Palindrome.IsPalindrome(userInput); if (result == true) { Console.WriteLine("The word is a Palindrome. \n"); } else { Console.WriteLine("The word is NOT a Palindrome. \n"); } do { Console.Write("Enter another word to test or type Exit to end: "); userInput = Console.ReadLine(); if (userInput == "Exit") { break; } result = Palindrome.IsPalindrome(userInput); if (result == true) { Console.WriteLine("The word is a Palindrome. Press enter to contiune. \n"); } else { Console.WriteLine("The word is NOT a Palindrome. Press enter to contiune. \n"); } } while (userInput != "Exit"); } catch (Exception ex) { Console.WriteLine("Please contact System Administrator"); } }
static void Main(string[] args) { Console.WriteLine("Let's test for palindromes!\n"); Console.WriteLine("Please enter a word."); // User Input string input = Console.ReadLine(); // Check to see if input is correct // If not, clear console. Console.WriteLine("Is this your word? (y/n)"); Console.Write("{0}: ", input); string yes_no = Console.ReadLine(); if (yes_no == "y" || yes_no == "yes") { Console.WriteLine("Calculating Palindromism... \n"); Palindrome.Tester(input); } else { Console.WriteLine("Trying again... \n"); Main(args); // Restart The Program } Console.ReadLine(); }
static void Main(string[] args) { var input = string.Empty; do { Console.WriteLine("Insert a string to check palindrome: "); input = Console.ReadLine(); if (Palindrome.Check(input)) { Console.WriteLine($" {input} is palindrome \n"); } else { Console.WriteLine($" {input} is not a palindrome \n"); } }while(input != "exit"); }
static void Main(string[] args) { string[] myWords = { "Madam", "nurses. run", "Rip City", "Lol", "rose garden" }; var palindrome = new Palindrome(); foreach (var word in myWords) { Console.WriteLine($"{word} = {palindrome.IsPalindrome(word)}"); } Console.ReadLine(); }
static void Main(string[] args) { var pl = new Palindrome(); int n; Console.Write("Enter a number: "); n = Convert.ToInt32(Console.ReadLine()); if (n == pl.rev(n)) { Console.Write("\n\tPalindrome"); } else { Console.Write("\n\tNot palindome"); } Console.ReadLine(); }
static void Main(string[] args) { IEnumerable <string> palindromes; var timer = Stopwatch.StartNew(); if (args.Count() >= 2) { palindromes = Palindrome.FindPalindromes(args.ToList()); } else { palindromes = Palindrome.FindPalindromes(GetNames()); } timer.Stop(); // Output Console.WriteLine("Found {0} palindromes in {1} milliseconds", palindromes.Count(), timer.ElapsedMilliseconds); WritePalindromes(palindromes); Console.ReadLine(); }
static void Main(string[] args) { while (true) { Console.WriteLine("Press 0 for exiting the program. "); Console.Write("Use English Only!\nInput your text: "); string input = Console.ReadLine(); Palindrome pl = new Palindrome(input); if (input.Equals("0")) { Console.WriteLine("Good Bye!!!"); break; } if (pl.checkPalindrome()) { Console.WriteLine("This input is palindrome.!"); } else { Console.WriteLine("This input is NOT palindrome.!"); } Console.WriteLine("------------------------------"); } }