Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace strong_number
- {
- class Program
- {
- static void Main()
- {
- //Sum Adjacent Equal Numbers
- // 3 3 4 = 6 4
- // 3 3 6 4 = 6 6 4 = 12 4
- List<double> list = Console.ReadLine().Split(' ').Select(double.Parse).ToList();
- int occured = 0;
- while (true)
- {
- for (int i=0; i< list.Count; i++)
- if (i + 1 < list.Count)
- {
- if (list[i] == list[i + 1])
- {
- list[i] += list[i + 1];
- list.RemoveAt(i + 1);
- break;
- }
- else
- {
- occured++;
- if (occured== list.Count - 1) { goto print; }
- }
- }
- occured = 0;
- }
- print:
- Console.WriteLine(string.Join(" ", list));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement