Skip to content

Instantly share code, notes, and snippets.

@DreamerDeLy
Last active April 25, 2020 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DreamerDeLy/74cc39ceba04b6d73549dc7ea3924f0b to your computer and use it in GitHub Desktop.
Save DreamerDeLy/74cc39ceba04b6d73549dc7ea3924f0b to your computer and use it in GitHub Desktop.
Task 17 [C#]
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();
}
}
}
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