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;
- namespace ConsoleApplication11
- {
- interface left
- {
- char[] shift();
- }
- interface right
- {
- char[] shift();
- }
- class MyClass:right, left
- {
- char[] m;
- public MyClass(char[] ar)
- {
- m = new char[ar.Length];
- m = ar;
- }
- char[] left.shift()
- {
- char item = m[0];
- char[] nc = new char[m.Length];
- for (int i = 1; i < m.Length; i++)
- nc[i - 1] = m[i];
- nc[m.Length - 1] = item;
- return nc;
- }
- char[] right.shift()
- {
- char item = m[m.Length - 1];
- char[] nc = new char[m.Length];
- for (int i = m.Length - 1; i > 0; i--)
- nc[i] = m[i - 1];
- nc[0] = item;
- return nc;
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- MyClass arr = new MyClass(new char[]{ '0', '1', '2'});
- left l = arr;
- right r = arr;
- Console.WriteLine(l.shift());
- Console.WriteLine(r.shift());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement