Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Hmwrk_3_6
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine().Split(',',' ','!','?',' ').ToArray();
- PalindromChecker(input);
- }
- private static void PalindromChecker(string[] array)
- {
- StringBuilder builder = new StringBuilder();
- Array.Sort(array);
- for (int i = 0; i < array.Length; i++)
- {
- string reversed = StringReverser(array[i]);
- if (array[i] == reversed)
- {
- builder.Append(reversed).Append(" ");
- }
- }
- string[] stringedBuilder = builder.ToString().Split(new char[] { ' ' },
- StringSplitOptions.RemoveEmptyEntries);
- Console.WriteLine(string.Join(", ",stringedBuilder));
- }
- private static string StringReverser(string strInput)
- {
- char[] charArray = strInput.ToCharArray();
- Array.Reverse(charArray);
- return new string(charArray);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement