Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _06._Palindrom
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- //aba -> aba
- //1a1 -> 1a1
- string text = Console.ReadLine();
- //текстът на обратно
- string reversedText = reverseString(text);
- if (text == reversedText)
- {
- //палиндром
- Console.WriteLine("True");
- }
- else
- {
- Console.WriteLine("False");
- }
- }
- static string reverseString(string text)
- {
- //text = "table";
- string reversedString = ""; //обърнатия текст -> "elbat"
- //от последния към първия символ
- for (int position = text.Length - 1; position >= 0; position--)
- {
- char currentSymbol = text[position];
- reversedString += currentSymbol;
- }
- return reversedString;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment