Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Messages
- {
- class Program
- {
- static void Main(string[] args)
- {
- int num = int.Parse(Console.ReadLine());
- string print = "";
- string output = "";
- for (int i = 0; i < num; i++)
- {
- int sms = int.Parse(Console.ReadLine());
- switch (sms)
- {
- case 2:
- print = "a";
- break;
- case 22:
- print = "b";
- break;
- case 222:
- print = "c";
- break;
- case 3:
- print = "d";
- break;
- case 33:
- print = "e";
- break;
- case 333:
- print = "f";
- break;
- case 4:
- print = "g";
- break;
- case 44:
- print = "h";
- break;
- case 444:
- print = "i";
- break;
- case 5:
- print = "j";
- break;
- case 55:
- print = "k";
- break;
- case 555:
- print = "l";
- break;
- case 6:
- print = "m";
- break;
- case 66:
- print = "n";
- break;
- case 666:
- print = "o";
- break;
- case 7:
- print = "p";
- break;
- case 77:
- print = "q";
- break;
- case 777:
- print = "r";
- break;
- case 7777:
- print = "s";
- break;
- case 8:
- print = "t";
- break;
- case 88:
- print = "u";
- break;
- case 888:
- print = "v";
- break;
- case 9:
- print = "w";
- break;
- case 99:
- print = "x";
- break;
- case 999:
- print = "y";
- break;
- case 9999:
- print = "z";
- break;
- case 0:
- print = " ";
- break;
- }
- output += print;
- }
- Console.WriteLine(output);
- }
- }
- }
- Решение с масив:
- using System;
- namespace Messages
- {
- class Program
- {
- static void Main(string[] args)
- {
- int num = int.Parse(Console.ReadLine());
- int[] button = { 32, 0, 97, 100, 103, 106, 109, 112, 116, 119 };
- string message = "";
- for (int i = 0; i < num; i++)
- {
- int current = int.Parse(Console.ReadLine());
- message += (char)(button[current % 10] + current.ToString().Length - 1);
- }
- Console.WriteLine(message);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement