Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.VisualBasic;
- namespace Reversing_and_Combining_Text
- {
- class Program
- {
- static void Main(string[] args)
- {
- string text = "abc def ghi jkl";
- List<string> str= new List<string> { };
- List<string> str2 = new List<string> { };
- str = text.Split(' ').ToList();
- int n=str.Count();
- int k;
- char temp;
- int spaces = n - 1;
- while( n !=1)
- {
- for (int i = 0; i < n; i++)
- {
- char[] arr = str[i].ToCharArray();
- k = arr.Length;
- for (int j = 0, h = k - 1; j < h; j++, h--)
- {
- temp = arr[j];
- arr[j] = arr[h];
- arr[h] = temp;
- }
- str[i] = String.Concat(arr);
- arr = null;
- }
- for (int i = 0; i < n - 1; i++)
- {
- str[i] += str[i + 1];
- }
- for (int i = 0; i < n; i++)
- {
- if (i % 2 == 0)
- {
- str2.Add(str[i]);
- }
- }
- str.Clear();
- for (int i = 0; i < str2.Count(); i++)
- {
- str.Add(str2[i]);
- }
- str2.Clear();
- n = str.Count();
- }
- string newText = string.Concat<string>(str);
- Console.WriteLine(newText);
- }
- }
- }
Add Comment
Please, Sign In to add comment