Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Palindrome using stack
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { Stack<char> cstack = new Stack<char>(); string input = "MALAYALAM"; var inputToUpper = input.ToUpper(); /*assuming case senstivity is not to be considered */ foreach (char c in inputToUpper) { cstack.Push(c); } bool isPalindrome = true; var noOfItems = cstack.Count; for(int i=0; i< noOfItems ; i++) { if (inputToUpper[i] != cstack.Pop()) { isPalindrome = false; break; } } if (isPalindrome) { Console.WriteLine("Palindrome"); } else { Console.WriteLine("Non Palindrome"); } } } }
run
|
edit
|
history
|
help
0
Pentagon`s area
group by
game 1.0.3
Random number guessing game v1
1. soru
D112
MightConst - Runtime Constwrapper Value (C#)
Modulul 3, Exerciţiul 2 – Crearea şi utilizarea unui tip struct
Chest Interaction Unity
a.out