Skip to content

Instantly share code, notes, and snippets.

@unilecs
Created November 22, 2023 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unilecs/1030d13856f4ccafaf0d7598eb585d8f to your computer and use it in GitHub Desktop.
Save unilecs/1030d13856f4ccafaf0d7598eb585d8f to your computer and use it in GitHub Desktop.
Задача: Исходный массив
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