Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5.  
  6. namespace ConsoleApplication {
  7.     internal class Program {
  8.         public static void Main(string[] args) {
  9.             var word = "mappm";
  10.             var s =  new Stack<char>();
  11.             for (int i = 0; i < word.Length / 2; i++) {
  12.                 s.Push(word[i]);
  13.             }
  14.             var isPalindrome = true;
  15.             for (int i = (int) Math.Ceiling((double) word.Length / 2); i < word.Length; i++) {
  16.                 if (word[i] != s.Pop()) {
  17.                     isPalindrome = false;
  18.                     break;
  19.                 }
  20.             }
  21.             if (isPalindrome)
  22.                 Console.WriteLine(word + " is palindrome");
  23.             else {
  24.                 Console.WriteLine("Failya!!");
  25.             }
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement