Advertisement
Grimmjow1

Messaging

Jun 19th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Messaging
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<int> numbers = Console.ReadLine().Split().Select(int.Parse).ToList();
  12.             string text = Console.ReadLine();
  13.             List<char> result = new List<char>();
  14.             for (int i = 0; i < numbers.Count; i++)
  15.             {
  16.                 int index = 0;
  17.                 while (numbers[i] != 0)
  18.                 {
  19.                     index += numbers[i] % 10;
  20.                     numbers[i] /= 10;
  21.                 }
  22.                 while (index > text.Length-1 )  // 55 2 3 4 5  index 10
  23.                 {
  24.                     index -= text.Length;
  25.                 }
  26.                 result.Add(text[index]);
  27.                text =  text.Remove(index, 1);
  28.                
  29.             }
  30.             Console.WriteLine(string.Join("",result));
  31.  
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement