Skip to content

Instantly share code, notes, and snippets.

@DreamerDeLy
Last active April 16, 2020 13:10
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/59b90943c341db5595d8856c6458eb55 to your computer and use it in GitHub Desktop.
Save DreamerDeLy/59b90943c341db5595d8856c6458eb55 to your computer and use it in GitHub Desktop.
Task 15 [C#]
using System;
namespace Task15
{
class Program
{
static string alph = "АБВГҐДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯ";
static void Main(string[] args)
{
string str = "";
string result = "";
Console.WriteLine("Enter string:");
str = Console.ReadLine();
str = str.ToUpper();
foreach(char c in str) // Строка теж масив
{
if (alph.Contains(c))
{
int n = alph.IndexOf(c);
result += (n + 1).ToString() + " "; // + 1 бо індекс від нуля
}
else
{
result += c;
}
}
Console.WriteLine("Result:");
Console.WriteLine(result);
Console.ReadKey();
}
}
}
C:\AP\Task15>dotnet run
Enter string:
Добрий ранок вам!
Result:
6 19 2 21 11 14 21 1 18 19 15 3 1 17 !
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment