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 Mover
- {
- class Program
- {
- static void Main(string[] args)
- {
- Mover mover = new Mover();
- Console.WriteLine("How many nubers do you want to move?");
- string sdimension = Console.ReadLine();
- mover.SetDimension(int.Parse(sdimension));
- for (int i = 0; i < mover.GetDimension(); i++)
- {
- Console.WriteLine("Please enter value of the number {0}", i + 1);
- string svalue = Console.ReadLine();
- mover.SetItemValue(i, int.Parse(svalue));
- }
- Console.WriteLine("By how much do you want to move them");
- string samount = Console.ReadLine();
- mover.amount = int.Parse(samount);
- mover.MoveU();
- Console.WriteLine("--------------------------");
- for (int i = 0; i < mover.GetDimension(); i++)
- {
- Console.WriteLine(mover.GetItemValue(i));
- }
- Console.WriteLine("By Danila Dudkin https://vk.com/dandelay");
- Console.ReadLine();
- }
- }
- class Mover
- {
- public int amount = 0;
- int[] numbers;
- int dimension;
- public string direction;
- public void SetDimension(int dimension)
- {
- this.dimension = dimension;
- Array.Resize(ref numbers, dimension);
- }
- public int GetDimension()
- {
- return dimension;
- }
- public void SetItemValue(int index, int value)
- {
- numbers[index] = value;
- }
- public int GetItemValue(int index)
- {
- return numbers[index];
- }
- public int[] GetArray()
- {
- return numbers;
- }
- public void MoveU()
- {
- for (int i = 0; i < amount; i++)
- {
- for (int j = 0; j < dimension - 1; j++)
- {
- int temporary;
- temporary = numbers[j];
- numbers[j] = numbers[j + 1];
- numbers[j + 1] = temporary;
- if (j == dimension - 1)
- {
- temporary = numbers[dimension];
- numbers[dimension] = numbers[dimension - (dimension - 1)];
- numbers[dimension - (dimension - 1)] = temporary;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement