Last active
April 16, 2020 13:10
-
-
Save DreamerDeLy/59b90943c341db5595d8856c6458eb55 to your computer and use it in GitHub Desktop.
Task 15 [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; | |
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(); | |
} | |
} | |
} |
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\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