Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp138
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] nums = Console.ReadLine()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- if (nums.Length < 2)
- {
- Console.WriteLine(OneDigit(nums));
- }
- if (nums.Length % 2 == 0)
- {
- Console.WriteLine(Even(nums));
- }
- }
- static int OneDigit(int[] nums)
- {
- int res = 0;
- foreach (var item in nums)
- {
- res = item;
- }
- return res;
- }
- static int[] Even(int[] nums)
- {
- int quantity = nums.Length;
- int[] res = new int[quantity];
- for (int i = 0; i < nums.Length; i++)
- {
- if (i == nums.Length / 2 - 1)
- {
- res[i] = nums[i];
- res[i + 1] = nums[i + 1];
- }
- nums[i] = res[i];
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement