Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NizNClanova
{
class Program
{
static void Main(string[] args)
{
int n, m, br, p;
int[] A, B;
Random rnd = new Random();

Console.WriteLine("Unesite dimenziju niza A");


n = int.Parse(Console.ReadLine());
A=new int[n]; //moramo da dimenzionisemo inicijalizujemo da bude n nula, niz
uvek tako ga uvek ispunimo celog nulama ili ne mozemo da ga koristimo
//Generisanje niza
for (int i = 0; i < n; i++)
{
A[i] = rnd.Next(0, 60);

}
//Sortiranje niza
for (int i = 0; i < n - 1; i++)
{
for (int j = i + 1; j < n; j++)
{
if(A[i]>A[j])
{
p=A[i];
A[i]=A[j];
A[j]=p;

}
}

//Broj clanova koje odbacujemo


Console.WriteLine("Unesite broj clanova koje odbacujemo?");
m = int.Parse(Console.ReadLine());

br = 0;
B=new int[n-2*m];

for(int i=m;i<n-m;i++)
{
B[br] = A[i];
br++;

Console.WriteLine("Niz A: ");
for (int i = 0; i < n; i++)
{
Console.Write(A[i] + "\t"); //write ostaje u istom redu, \t je tabulator
da se pomeri da ne budu sabijeni brojevi
}

Console.WriteLine();
Console.WriteLine("Niz B: ");
for (int i = 0; i < n - 2 * m; i++)
{
Console.Write(B[i] + "\t");
}

}
}
}

You might also like