-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStringReverse.cs
72 lines (63 loc) · 2.89 KB
/
StringReverse.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*-----------------------------------------------------------------------------
* HTBLA-Leonding / Class: 3ACIF
*-----------------------------------------------------------------------------
* Jan Ritt
*-----------------------------------------------------------------------------
* Description: string manipulation without standard methods
*-----------------------------------------------------------------------------
*/
/*_________________________________libraries_________________________________*/
using System; //
using System.Diagnostics.Metrics;
using System.Text; // Unicode Symbols
using System.Threading; // Thread.Sleep(1000) = 1 sec
/*---------------------------------- START ----------------------------------*/
namespace StringReverse //
{ //
public class Program //
{ //
static void Main() //
{
///*----------------------- console_settings ------------------------*///
const int cWidth = 53; // console width
const int cHeight = 30; // & height
Console.SetWindowSize(cWidth, cHeight); //
Console.OutputEncoding = Encoding.UTF8; // Unicode Symbols
/*----------------------------- VARIABLES -----------------------------*/
string userInput;
int index,
lenght = 0;
/*-------------------------------- HEAD -------------------------------*/
Console.Clear();
Console.Write("\n Reverse String " +
/* cWidth: */ "\n=====================================================");
/*---[in:]-------------------- PROMPT_USER ----------------------------*/
Console.Write("\n Geben Sie einen Text ein."); //
/*----------------------------- GET_INPUT -----------------------------*/
userInput = Console.ReadLine(); // get input + [enter]
//
foreach (char letter in userInput)
{
lenght++;
}
Console.Write($"\n Länge:{lenght}\n\n");
char[] charsInput = new char[lenght];
for (int i = 0; i < lenght; i++)
{
char letter = userInput[i];
charsInput[i] = letter;
}
/*---[out:]--------------------- SOLUTION -----------------------------*/
index = lenght - 1;
do
{
Console.Write($"{charsInput[index]}");
index--;
} while (index >= 0);
/*-------------------------------- END --------------------------------*/
Console.Write("\n Zum beenden Eingabetaste drücken..");
Console.ReadLine(); // wait for [enter]
Console.Clear(); //
}
}
}