Created
May 17, 2016 06:37
-
-
Save vdonchev/26d6775e46ea418f87ea19bc63db71c6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| namespace Medenka | |
| { | |
| using System; | |
| using System.Text; | |
| public static class Medenka | |
| { | |
| private static StringBuilder result = new StringBuilder(); | |
| static void Main(string[] args) | |
| { | |
| var arr = Console.ReadLine().Split(); | |
| Cut(arr, string.Empty); | |
| Console.WriteLine(result.ToString().Trim()); | |
| } | |
| private static void Cut(string[] arr, string res, int index = 0, bool found = false) | |
| { | |
| while (index < arr.Length) | |
| { | |
| if (arr[index] == "1") | |
| { | |
| if (found) | |
| { | |
| res += "|1"; | |
| } | |
| else | |
| { | |
| res += "1"; | |
| found = true; | |
| } | |
| } | |
| else | |
| { | |
| if (found) | |
| { | |
| Cut(arr, res + "|0", index + 1); | |
| } | |
| res += "0"; | |
| } | |
| index++; | |
| } | |
| result.AppendLine(res); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment