3. uzdevums
Veidoja Ilgvars Līckrastiņš 04.03.2025
Vide: Programiz C# Online Compiler




using System;
using System.Text;

class Program
{
	static void Main()
	{
    	Console.Write("Ilgvars L. 110.grupa");
    	Console.WriteLine();
    	Console.Write("Ievadi tekstu: ");
    	string text = Console.ReadLine();

    	// Izveido un izvada reversed vardu secibu
    	string reversedWords = ReverseWordOrder(text);
    	Console.WriteLine("Reversed vardu seciba: " + CapitalizeFirstLetter(reversedWords));

    	// Izveido un izvada pilniba reversed teikumus/vardu
    	string reversedSentence = ReverseFullText(reversedWords);
    	Console.WriteLine("Apgriezts teksts: " + CapitalizeFirstLetter(reversedSentence));


    	DisplayCenteredText(text);

    	ReplaceTextWithSpaces(text);


    	RevealTextFromEnd(text);


    	RemoveCharacterFromEnd(text);
	}

	static string ReverseWordOrder(string input)
	{
    	string[] words = input.Split(' ');
    	Array.Reverse(words);
    	return string.Join(" ", words);
	}


	static string ReverseFullText(string input)
	{
    	char[] chars = input.ToCharArray();
    	Array.Reverse(chars);
    	return new string(chars);
	}


	static string CapitalizeFirstLetter(string input)
	{
    	if (string.IsNullOrEmpty(input)) return input;
    	return char.ToUpper(input[0]) + input.Substring(1);
	}


	static void DisplayCenteredText(string input)
	{
    	int length = input.Length;
    	StringBuilder sb = new StringBuilder(new string(' ', length));

    	for (int i = 0; i <= length / 2; i++)
    	{
        	sb[length / 2 - i] = input[length / 2 - i];
        	sb[length / 2 + i] = input[length / 2 + i];
        	Console.WriteLine(sb.ToString());
    	}
	}

	// Parada tekstu, aizstajot atstarpes
	static void ReplaceTextWithSpaces(string input)
	{
    	int length = input.Length;
    	StringBuilder sb = new StringBuilder(input);

    	for (int i = 0; i <= length / 2; i++)
    	{
        	sb[length / 2 - i] = ' ';
        	sb[length / 2 + i] = ' ';
        	Console.WriteLine(sb.ToString());
    	}
	}

	// Atklaj tekstu no beigam uz sakumu
	static void RevealTextFromEnd(string input)
	{
    	int length = input.Length;
    	StringBuilder sb = new StringBuilder(new string(' ', length));

    	for (int i = length - 1; i >= 0; i--)
    	{
        	sb[i] = input[i];
        	Console.WriteLine(sb.ToString());
    	}
	}

	// Nonem no varda pedejo burtu un izvada to
	static void RemoveCharacterFromEnd(string input)
	{
    	StringBuilder sb = new StringBuilder(input);
    	while (sb.Length > 0)
    	{
        	sb.Remove(sb.Length - 1, 1); // Tiek nonemts pedejais burts
        	Console.WriteLine(sb.ToString());
    	}
	}
}


