Created
November 22, 2023 05:22
-
-
Save unilecs/1030d13856f4ccafaf0d7598eb585d8f to your computer and use it in GitHub Desktop.
Задача: Исходный массив
This file contains 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
using System; | |
public class Program | |
{ | |
public static int[] FindOriginArray(int[] pref) | |
{ | |
int[] res = new int[pref.Length]; | |
res[0] = pref[0]; | |
for (int i = 1; i < pref.Length; i++) | |
{ | |
res[i] = pref[i - 1] ^ pref[i]; | |
} | |
return res; | |
} | |
public static void Main() | |
{ | |
Console.WriteLine("UniLecs"); | |
// tests | |
Console.WriteLine(string.Join(", ", FindOriginArray(new int[] { 5, 2, 0, 3, 1 }))); // [5, 7, 2, 3, 2] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment