Last active
April 25, 2020 18:43
-
-
Save DreamerDeLy/74cc39ceba04b6d73549dc7ea3924f0b to your computer and use it in GitHub Desktop.
Task 17 [C#]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
namespace Task17 | |
{ | |
class Program | |
{ | |
static string alph = "АБВГҐДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯ"; | |
static void Main(string[] args) | |
{ | |
Console.OutputEncoding = Encoding.Unicode; | |
Console.InputEncoding = Encoding.Unicode; | |
string str = ""; | |
string result = ""; | |
Console.WriteLine("Enter string:"); | |
str = Console.ReadLine(); | |
for (int i = 0; i < str.Length; i++) | |
{ | |
char ch = str[i]; | |
bool is_lower = char.IsLower(ch); | |
ch = char.ToUpper(ch); | |
if (alph.Contains(ch)) | |
{ | |
int n = alph.IndexOf(ch); | |
ch = alph[alph.Length - n - 1]; | |
if (is_lower) ch = char.ToLower(ch); | |
result += ch; | |
} | |
else | |
{ | |
result += ch; | |
} | |
} | |
Console.WriteLine("Result:"); | |
Console.WriteLine(result); | |
Console.ReadKey(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C:\AP\Task17>dotnet run | |
Enter string: | |
Добри ранок, Україно! | |
Result: | |
Чкюїт їялко, Зоїярлк! | |
C:\AP\Task17>dotnet run | |
Enter string: | |
Чкюїт їялко, Зоїярлк! | |
Result: | |
Добри ранок, Україно! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment