Advertisement
Honza_Tajovsky

Oprava palindrom - David

Jun 23rd, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1.             // Dva středníky za sebou neberu jako chybu
  2.             // Vstup je nutno ale převést na malá resp. velká písmena
  3.             // aby prošla i "Mom"
  4.             //string input = Console.ReadLine(); ;
  5.             string input = Console.ReadLine().ToLower();
  6.            
  7.             // palindrom s Y neberu jako chybu
  8.             bool palyndrom = true;
  9.  
  10.             for (int x = 0; x < input.Length / 2; x++)
  11.             {
  12.                 if (input[x] != input[input.Length - x - 1])
  13.                 {
  14.                     palyndrom = false;
  15.                     break;
  16.                 }
  17.             }
  18.  
  19.             if (palyndrom) Console.WriteLine(input + " je palyndrom");
  20.             else Console.WriteLine(input + " neni palyndrom");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement