Write a C# Sharp program to create a new array of integers and length 1 or more. The length of the new array will be double length of the given array and all the elements are 1 except the first element which is equal to the given array
- برمجة سي شارب
- برمجة
- 2021-05-17
- MarwaMohammed
الأجوبة
using System;
namespace exercises
{
class Program
{
static void Main(string[] args)
{
int[] item = test(new[] { 10, 20, -30, -40, 30 });
Console.Write("New array: ");
foreach(var i in item)
{
Console.Write(i.ToString()+" ");
}
}
public static int[] test(int[] nums)
{
int elements = nums.Length * 2;
int[] doubleNums = new int[elements];
doubleNums[0] = nums[0];
return doubleNums;
}
}
}
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال