Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.InteropServices;
- namespace ConsoleApplication {
- internal class Program {
- public static void Main(string[] args) {
- var word = "mappm";
- var s = new Stack<char>();
- for (int i = 0; i < word.Length / 2; i++) {
- s.Push(word[i]);
- }
- var isPalindrome = true;
- for (int i = (int) Math.Ceiling((double) word.Length / 2); i < word.Length; i++) {
- if (word[i] != s.Pop()) {
- isPalindrome = false;
- break;
- }
- }
- if (isPalindrome)
- Console.WriteLine(word + " is palindrome");
- else {
- Console.WriteLine("Failya!!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement