For example and array containing 3, 4, 2, 1, 5 should end us as 2, 4, 1, 3, 5.
using System;
namespace HelloWorld
{
class Program
{
static string GetArrayAsString(int[] array)
{
if(array.Length == 0) return "";
string str = "";
int i = 0;
for(; i < array.Length - 1; i++)
{
str += array[i] + ", ";
}
str += array[i];
return str;
}
static void Main(string[] args)
{
int[] numbers = {3, 4, 2, 1, 5};
Separate(numbers);
Console.WriteLine(GetArrayAsString(numbers));
}
}
}
namespace HelloWorld
{
class Program
{
static string GetArrayAsString(int[] array)
{
if(array.Length == 0) return "";
string str = "";
int i = 0;
for(; i < array.Length - 1; i++)
{
str += array[i] + ", ";
}
str += array[i];
return str;
}
static void Main(string[] args)
{
int[] numbers = {3, 4, 2, 1, 5};
Separate(numbers);
Console.WriteLine(GetArrayAsString(numbers));
}
}
}
Sreekanth ReddyPosted Dec 19, 2018, 11:24 PM