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 ConsoleApplication7
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Unesite veličinu niza: ");
- int vel = int.Parse(Console.ReadLine());
- int[] niz = new int[vel];
- Console.WriteLine("Unesite {0} brojeva: ", vel);
- for (int i = 0; i < vel; i++)
- {
- niz[i] = int.Parse(Console.ReadLine());
- }
- int size = niz.Length;
- Program.sort(niz);
- Console.WriteLine("Unesite broj koji želite izbaciti");
- int br = int.Parse(Console.ReadLine());
- Program.izbaci(br,ref size, niz);
- for (int i = 0; i < size; i++)
- {
- Console.WriteLine(niz[i]);
- }
- Console.ReadLine();
- }
- static void sort(params int[] niz)
- {
- for (int i = 0; i < niz.Length; i++)
- {
- for (int j = i+1; j < niz.Length; j++)
- {
- if (niz[i] > niz[j])
- {
- int temp = niz[i];
- niz[i] = niz[j];
- niz[j] = temp;
- }
- }
- }
- }
- static void izbaci(int a, ref int vel, params int[] niz)
- {
- for(int i=0; i<vel; i++)
- {
- if(niz[i]==a){
- for(int j=i; j<vel-1; j++)
- niz[j]=niz[j+1];
- i--;
- vel--;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement