Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace fundamental14
- {
- class MainClass
- {
- public static void Main()
- {
- List<string> numbers = Console.ReadLine().Split().ToList();
- string text = Console.ReadLine();
- List<char> duma = new List<char>();
- List<string> final = new List<string>();
- List<int> index = new List<int>();
- for (int i = 0; i < text.Length; i++)
- {
- duma.Add(text[i]);
- }
- int sum = 0;
- for (int i = 0; i < numbers.Count; i++)
- {
- string amount = numbers[i];
- for (int z = 0; z < amount.Length; z++)
- {
- int chislo = int.Parse(amount[z].ToString());
- sum += chislo;
- }
- if (duma.Count < sum)
- {
- sum = sum - duma.Count;
- }
- index.Add(sum);
- sum = 0;
- }
- for (int j = 0; j < index.Count; j++)
- {
- int removeIndex = index[j];
- final.Add(duma[removeIndex].ToString());
- duma.RemoveAt(removeIndex);
- }
- for (int k = 0; k < final.Count; k++)
- {
- Console.Write(final[k]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement