using System using System Collections Generic using System Linq using

  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
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class intList
{
int[] M;
int count = 0;
int Capacity;
const int defaultCapacity = 10;
public intList (int a)
{
this.M = new int[a];
Capacity = a;
}
public void add(int a)
{
this.M[count] = a;
this.count++;
}
public void addrange(int[] a)
{
for (int i = 0; i < a.Length; i++)
{
this.M[count] = a[i];
count++;
}
}
public void clear()
{
for (int i = Capacity; i >= 0; i++)
{
this.M[i] = 0;
}
}
public bool Contains(int a)
{
bool b = false;
for (int i = 0; i < count; i++)
{
if (this.M[i] == a)
{
b = true;
}
}
return b;
}
public void CopyTo(intList a)
{
this.M = a.M;
this.count = a.count;
}
public System.Collections.IEnumerator GetEnumerator()
{
for (int i = 0; i < this.count; i++)
{
yield return M[i];
}
}
public static intList operator <<(intList a, int b)
{
intList qwe = new intList(a.count);
for (int i = 0; i < a.count - b; i++)
{
qwe.M[i] = a.M[i + b];
}
for (int i = a.count - b; i < a.count; i++)
{
qwe.M[i] = a.M[i + b - a.count];
}
return qwe;
}
public int this[int i]
{
get { return M[i]; }
set {M[i] = value;}
}
}
class Program
{
static void Main(string[] args)
{
intList IL = new intList(10);
IL.add(1);
IL.add(2);
IL.add(3);
IL.add(4);
IL.add(5);
IL.addrange(new int[] { 6, 7, 8, 9 });
for (int i = 0; i < 9; i++)
{
Console.Write(" {0}", IL[i]);
}
Console.WriteLine();
IL = IL << 7;
for (int i = 0; i < 9; i++)
{
Console.Write(" {0}", IL[i]);
}
Console.WriteLine();
}
}
}