using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace multime
{
class vector
{
protected int n;
protected int[] a;
public vector()
{
n = 0;
}
public vector(int m, int[] b)
{
n = m;
a = new int[n];
for (int i = 0; i < n; i++)
a[i] = b[i];
}
virtual public void citire()
{
Console.Write("n=");
n = Int32.Parse(Console.ReadLine());
a = new int[n];
for (int i = 0; i < n; i++)
{
Console.Write("a[" + i + "]=");
a[i] = Int32.Parse(Console.ReadLine());
}
}
virtual public void afis()
{
Console.WriteLine("n=" + n);
for (int i = 0; i < n; i++)
Console.Write(a[i] + " ");
}
}
class multime : vector
{
private void transforma()
{
int i, aux;
bool gata;
do
{
gata = true;
for (i = 0; i < n - 1; i++)
if (a[i] > a[i + 1])
{
aux = a[i];
a[i] = a[i + 1];
a[i + 1] = aux;
gata = false;
}
}
while (!gata);
int j;
for(i=0;i<n-1;i++)
if (a[i] == a[i + 1])
{
for (j = i + 1; j < n - 1; j++)
a[j] = a[j + 1];
n--;
i--;
}
}
public multime()
: base()
{
}
public multime(int m, int[] b)
: base(m, b)
{
transforma();
}
override public void citire()
{
base.citire();
transforma();
}
}
class Program
{
static void Main(string[] args)
{
vector v = new multime();
v.citire();
v.afis();
Console.ReadKey();
}
}
}
|