-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathChanging Odd and Even Places of the Given Array.cs
More file actions
43 lines (42 loc) · 1.2 KB
/
Copy pathChanging Odd and Even Places of the Given Array.cs
File metadata and controls
43 lines (42 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication65
{
class Program
{
static void Main(string[] args)
{
int i, j=0, N;
Console.WriteLine("Changing the even places and odd places of the input array");
Console.WriteLine("Enter the Maximum Range");
N = Convert.ToInt32(Console.ReadLine());
int[] a = new int[N];
Console.WriteLine("Enter the values:");
for (i = 0; i < N; i++)
{
a[i] = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("The input values entered are:");
for (i = 0; i < N; i++)
{
Console.Write("{0} ", a[i]);
}
Console.WriteLine("\n");
for (i = 0; i < N-1; i++)
{
j = a[i];
a[i] = a[i + 1];
a[i + 1] = j;
}
for (i = 0; i < N; i++)
{
Console.Write("{0} ", a[i]);
}
Console.WriteLine("\n");
Console.ReadLine();
}
}
}