using static System.Console;
using static System.Diagnostics.Contracts.Contract;
public class Program {
public static void Main() {
foreach (var item in ReplaceRange(new int[] {0, 1, 2, 3, 4}, new int[] {5, 6, 7, 8, 9}, 2)) WriteLine(item);
}
public static T[] ReplaceRange<T>(T[] source, T[] destination, int start) {
Requires(start >= 0, "O índice de início não pode ser menor que zero");
Requires(start < source.Length, "O índice de início não pode ser maior que o fim do array");
Requires(destination.Length >= source.Length - start, "O índice de início não pode ser maior que o que cabe");
for (int i = start, j = 0; i < source.Length; i++, j++) destination[i] = source[j];
return destination;
}
}
//https://pt.stackoverflow.com/q/314158/101
dXNpbmcgc3RhdGljIFN5c3RlbS5Db25zb2xlOwp1c2luZyBzdGF0aWMgU3lzdGVtLkRpYWdub3N0aWNzLkNvbnRyYWN0cy5Db250cmFjdDsKCnB1YmxpYyBjbGFzcyBQcm9ncmFtIHsKCXB1YmxpYyBzdGF0aWMgdm9pZCBNYWluKCkgewoJCWZvcmVhY2ggKHZhciBpdGVtIGluIFJlcGxhY2VSYW5nZShuZXcgaW50W10gezAsIDEsIDIsIDMsIDR9LCBuZXcgaW50W10gezUsIDYsIDcsIDgsIDl9LCAyKSkgV3JpdGVMaW5lKGl0ZW0pOwoJfQoJcHVibGljIHN0YXRpYyBUW10gUmVwbGFjZVJhbmdlPFQ+KFRbXSBzb3VyY2UsIFRbXSBkZXN0aW5hdGlvbiwgaW50IHN0YXJ0KSB7CgkJUmVxdWlyZXMoc3RhcnQgPj0gMCwgIk8gw61uZGljZSBkZSBpbsOtY2lvIG7Do28gcG9kZSBzZXIgbWVub3IgcXVlIHplcm8iKTsKCQlSZXF1aXJlcyhzdGFydCA8IHNvdXJjZS5MZW5ndGgsICJPIMOtbmRpY2UgZGUgaW7DrWNpbyBuw6NvIHBvZGUgc2VyIG1haW9yIHF1ZSBvIGZpbSBkbyBhcnJheSIpOwoJCVJlcXVpcmVzKGRlc3RpbmF0aW9uLkxlbmd0aCA+PSBzb3VyY2UuTGVuZ3RoIC0gc3Rhcn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