NIZOVI.

Similar documents
pojedinačnom elementu niza se pristupa imeniza[indeks] indeks od 0 do n-1

namespace spojneice { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

... ; ako je a n parno. ; ako je a n neparno

I PISMENI ZADATAK III6 I GRUPA IME I PREZIME

b) program deljiv3; uses wincrt; var i:integer; begin i:=3; while i<100 do begin write(i:5); i:=i+3; end; end.

Programiranje III razred

CALCULATOR APPLICATION

for i:=2 to n do if glasovi[i]>max then begin max:=glasovi[i]; k:=i {*promenljiva k ce cuvati indeks takmicara sa najvise glasova *} end;

Osnove programskog jezika C# Čas 5. Delegati, događaji i interfejsi

Object oriented lab /second year / review/lecturer: yasmin maki

/*#include <iostream> // Prvi zadatak sa integralnomg ispita

if (say==0) { k.commandtext = "Insert into kullanici(k_adi,sifre) values('" + textbox3.text + "','" + textbox4.text + "')"; k.

Now find the button component in the tool box. [if toolbox isn't present click VIEW on the top and click toolbox]

Veverica (za ocene >=3)

Uvod u programiranje - vežbe. Kontrola toka izvršavanja programa

Univerzitet u Nišu Građevinsko-arhitektonski fakultet. 4. Ciklična algoritamska struktura 5. Jednodimenzionalno polje.

CSIS 1624 CLASS TEST 6

To start we will be using visual studio Start a new C# windows form application project and name it motivational quotes viewer

UNIVERZITET U BEOGRADU ELEKTROTEHNIČKI FAKULTET

var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin ListBox1.Items.LoadFromFile('d:\brojevi.

Uvod u relacione baze podataka

Experiment 5 : Creating a Windows application to interface with 7-Segment LED display

x y = z Zadaci - procedure

Rekurzivne metode. Posmatrajmo rekurzivan metod kojim u objektu listbox1 klase ListBox upisujemo sve prirodne brojeve od 1 do datog n.

Izrada VI laboratorijske vježbe

Nizovi. Programiranje 1

Main Game Code. //ok honestly im not sure, if i guess its a class ment for this page called methodtimer that //either uses the timer or set to timer..

First start a new Windows Form Application from C# and name it Interest Calculator. We need 3 text boxes. 4 labels. 1 button

You can call the project anything you like I will be calling this one project slide show.

LISTING PROGRAM. // // TODO: Add constructor code after the InitializeComponent() call. //

create database ABCD use ABCD create table bolumler ( bolumkodu int primary key, bolumadi varchar(20) )

C# winforms gridview

Programiranje Programski jezik C. Sadržaj. Datoteke. prof.dr.sc. Ivo Ipšić 2009/2010

The Gracefulness of the Merging Graph N ** C 4 with Dotnet Framework

VRIJEDNOSTI ATRIBUTA

Računarske osnove Interneta (SI3ROI, IR4ROI)

KONTROLE IZBORA_- Kontrola ListBox

Sub To Srt Converter. This is the source code of this program. It is made in C# with.net 2.0.

IBSDK Quick Start Tutorial for C# 2010

Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK.

Uputa: Zabranjeno je koristiti bilo kakva pomagala. Rje²enja pi²ete desno od zadatka. Predajete samo ovaj list.

// Specify SEF file to load. edischema oschema = oedidoc.loadschema(spath + sseffilename, SchemaTypeIDConstants. Schema_Standard_Exchange_Format);

Informacioni sistemi i baze podataka

Algoritmi i strukture podataka 2. Čas, Uvod u C++

PREDMET. Osnove Java Programiranja. Čas JAVADOC

// Specify SEF file to load. oschema = (edischema) oedidoc.loadschema(spath + sseffilename, SchemaTypeIDConstants. Schema_Standard_Exchange_Format);

string spath; string sedifile = "277_005010X228.X12"; string sseffile = "277_005010X228.SemRef.EVAL0.SEF";

The Open Core Interface SDK has to be installed on your development computer. The SDK can be downloaded at:

Answer on Question# Programming, C#

VHDLPrimeri Poglavlje5.doc

Visual Basic/C# Programming (330)

Start Visual Studio and create a new windows form application under C# programming language. Call this project YouTube Alarm Clock.

Vežbe - XII nedelja PHP Doc

For. 1) program ispis; {ispisuje brojeve od 1 do 5 jedan ispod drugog} uses wincrt; var s,i:integer; begin for i:=1 to 5do writeln(i); end.

We are going to use some graphics and found a nice little batman running GIF, off course you can use any image you want for the project.

How to create a simple ASP.NET page to create/search data on baan using baan logic from the BOBS client sample.

Overview. Building a Web-Enabled Decision Support System. Integrating DSS in Business Curriculum. Introduction to DatabaseSupport Systems

Programiranje kroz aplikacije. Kontrola toka programa Nizovi

Form Properties Window

Class Test 4. Question 1. Use notepad to create a console application that displays a stick figure. See figure 1. Question 2

PHP? PHP (recursive acronym "PHP: Hypertext Preprocessor") Open Source general-purpose scripting language Web development

Fortran 90. Numeričke Metode DECEMBAR ĐURĐEVAC NATAŠA

Numeričke metode i praktikum

Prirodno-matematički fakultet u Nišu Departman za fiziku. dr Dejan S. Aleksić Programiranje u fizici

Tema 8: Koncepti i teorije relevantne za donošenje odluka (VEŽBE)

II. Programming Technologies

Učitati cio broj n i štampati njegovu recipročnu vrijednost. Ako je učitan broj 0, štampati 1/0.

APÉNDICE J. CÓDIGO DEL ARCHIVO FORM1.CS EN LENGUAJE C# Comprende:

Create your own Meme Maker in C#

PRIJEMNI ISPIT IZ INFORMATIKE

24/03/2018. Deklaracija promenljivih. Inicijalizacija promenljivih. Deklaracija i inicijalizacija promenljivih

Lab - 1. Solution : 1. // Building a Simple Console Application. class HelloCsharp. static void Main() System.Console.WriteLine ("Hello from C#.

Click on the empty form and apply the following options to the properties Windows.

Vidljivost TipPovratneVrednosti ImeFunkcije (NizParametara) { TeloFunkcije }

NI USB-TC01 Thermocouple Measurement Device

UPUTSTVO ZA KORIŠĆENJE NOVOG SPINTER WEBMAIL-a

เว บแอพล เคช น. private void Back_Click(object sender, EventArgs e) { this.webbrowser2.goback(); }

Uvod u programiranje

C:\homeworks\PenAttention_v13_src\PenAttention_v13_src\PenAttention4\PenAttention\PenAttention.cs 1 using System; 2 using System.Diagnostics; 3 using

namespace csharp_gen277x214 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

Huw Talliss Data Structures and Variables. Variables

Mainly three tables namely Teacher, Student and Class for small database of a school. are used. The snapshots of all three tables are shown below.

Conventions in this tutorial

بسم هللا الرحمن الرحيم المحاضرة السابعة مستوى ثالث علوم حاسوب برمجة مرئية 2 )عملي ) جامعة الجزيرة محافظة اب الجمهورية اليمنية النافذة الرئيسية

LISTING PROGRAM. //Find the maximum and minimum values in the array int maxvalue = integers[0]; //start with first element int minvalue = integers[0];

This is the empty form we will be working with in this game. Look under the properties window and find the following and change them.

Start Visual Studio, create a new project called Helicopter Game and press OK

LAMPIRAN A : LISTING PROGRAM

} } public void getir() { DataTable dt = vt.dtgetir("select* from stok order by stokadi");

APARAT DE MASURA. Descrierea programului

Z1. Dati RDF graf predstavljen u JSON-LD sintaksi potrebno je grafički predstaviti u skladu sa RDF notacijom. (5 poena)

Kada se pokrene forma da bude plave boje. Dugme Crtaj krugove da iscrtava slučajan broj N krugova istog poluprečnika r (1/4 visine forme) čiji su

Визуал програмчлал. Багш: Ж. Шинэбаяр /Маг/

Savoy ActiveX Control User Guide

Representing Recursive Relationships Using REP++ TreeView

namespace csharp_gen837x223a2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

Writing Your First Autodesk Revit Model Review Plug-In

Visual Basic/C# Programming (330)

namespace Gen837X222A1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

Tutorial 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and Arithmetic

Transcription:

NIZOVI LINKOVI ZA KONZOLNI C# OSNOVNO http://www.mycity.rs/net/programiranje-u-c-za-osnovce-i-srednjoskolce.html http://milan.milanovic.org/skola/csharp-00.htm Niz deklarišemo navođenjem tipa elemenata za kojim sledi par srednjih zagrada[] i naziv niza. Ako je niz višedimenzionalni između zagrada[] se navode zarezi, čiji je broj za jedan manji od dimenzija niza. Bez obzira da li je tip elemnata niza vrednosni ili referentni, niz je referentni tip podataka, pa se pri deklaraciji ne rezerviše prostor za elemente niza. Rezerviše se u toku izvršavanja aplikacije u trenutku definisanja niza Da bi se deklarisala nizovna promenljiva potrebno je: navesti tip elemenata niza, zatim uglaste zagrade kojima se specificira rang niza, i na kraju ime nizovne promenljive. Primer deklaracije promenljive: Tip[] imepromenljive; int[] MojNiz; - Tip elemenata niza može biti bilo koji tip uključujući i nizovni tip - Podržani su: a) jednodimenzionalni nizovi, b) dvodimenzionalni nizovi (matrice) c) nizovi nizova int[] MojNiz=new int[10] Pen[] olovke=new Pen[15] - definisan je niz MojNiz celih brojeva i odvojen prostor za registrovanje 10 celih brojeva pri definiciji niza Olovke odvaja se prostor za registrovanje 15 referenci (adresa) na objekte klase Pen, ali ti objekti nisu kreirani, već svi elementi niza imaju vrednost null Inicijalizacija niza: x=new int[5] 2, 33, 4, 55, 6 - može se izostaviti kapacitet niza, ako su elementi niza inicijalizovani x=new int[ ] 2, 33, 4, 55, 6 int[] y=2, 33, 4, 55, 6 int[,] matrica = new int[3,2] 1, 2, 3, 4, 5, 6 ; dvodimenzionalni niz pojedinačnom elementu niza se pristupa imeniza[indeks] indeks od 0 do n-1 (n-broj elemenata niza) 1. Unos elemenata niza textbox int[] x=new int[40]; int n=0,i=0; x[i] = Convert.ToInt32(textBox1.Text); //unesi x listbox1.items.add("x[" + i + "]=" + x[i]); i++; listbox1.text = "x[" + i + "]="; //priprema za sledeci textbox1.text = ""; n = i; //odredjivanje broja elemenata u nizu button1.enabled = false; //kraj niza, nema vise unosa button2.enabled = true; 1

2.Generisati niz od n celih brojeva slučajno izabranih sa intervala[a,b] int n = Convert.ToInt32(textBox1.Text); int a = Convert.ToInt32(textBox2.Text); int b = Convert.ToInt32(textBox3.Text); listbox1.items.clear(); Random R = new Random(); int[] X; X =new int[n]; for(int i=0;i<n;i++) X[i]=R.Next(a,b+1); listbox1.items.add("x["+i+"]= "+X[i]); 3.Pronaći najveći element unetog niza realnih elemenata dužine n. (Unos InputBox) using Microsoft.VisualBasic; double max; int n = Convert.ToInt32(textBox4.Text); double[] Niz = new double[n]; Niz[i] = Convert.ToDouble(Interaction.InputBox(i + ".clan", "Unos elemenata niza", "", -1, -1)); listbox2.items.add(niz[i]); max = Niz[0]; for (int i = 1; i < n; i++) if (max < Niz[i]) max = Niz[i]; textbox5.text = max.tostring(); 2

4. U tekstualnoj datoteci sa.txt (bin/debug) se nalazi u prvom redu dužina niza, a u ostalim redovima članovi niza. Treba pročitati i ispisati članove niza u listbox using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; void IspisiNiz(int[] a, int n, ListBox lb) lb.items.add(a[i].tostring()); StreamReader sr = new StreamReader("ElementiNiza.txt"); int n = Convert.ToInt32(sr.ReadLine()); int [] a = new int[n]; a[i] = Convert.ToInt32(sr.ReadLine()); sr.close(); IspisiNiz(a, n, listbox1); 3

5.Napisati metode kojima se: - generiše niz slučajnih brojeva iz intervala[a,b], a dužina niza generiše slučajnim brojem[10,100]; - generiše niz celih brojeva čitanjem iz tekstualnog fajla, gde se u prvom redu nalazi broj elemenata niza, a u svakom sledećem elementi niza; -prikazuju redom svi elementi niza u objektu klase ListBox; public Form1() InitializeComponent(); void generisi(int a, int b, Random R, out int n, out int[] x) n = R.Next(10, 101); x = new int[n]; x[i] = R.Next(a, b + 1); void citaj(string imefajla, out int[] x, out int n) StreamReader sr = new StreamReader(imeFajla); n = Convert.ToInt32(sr.ReadLine()); x = new int[n]; x[i] = Convert.ToInt32(sr.ReadLine()); sr.close(); void pisi(int[] x, int n, ListBox lb) lb.items.add(x[i]); int[] x; int n; Random R = new Random(); int a = Convert.ToInt32(textBox1.Text); int b = Convert.ToInt32(textBox2.Text); generisi(a,b,r,out n,out x); listbox1.items.clear(); pisi(x, n, listbox1); if (!File.Exists(textBox3.Text)) MessageBox.Show("Nema fajla tog imena"); return; citaj(textbox3.text, out x, out n); listbox2.items.clear(); pisi(x, n, listbox2); 4

6. public partial class Form1 : Form public Form1() InitializeComponent(); int[] x=new int[40]; int n=0,i=0; label1.text = "x[0]="; //inicijalizacija x[i] = Convert.ToInt32(textBox1.Text); //unesi x listbox1.items.add("x[" + i + "]=" + x[i]); i++; listbox1.text = "x[" + i + "]="; //priprema za sledeci textbox1.text = ""; n = i; //odredjivanje broja elemenata u nizu button1.enabled = false; //kraj niza, nema vise unosa button2.enabled = true; label1.text = ""; //brisemo tekst x[...]= textbox2.text = "Niz ima " + n.tostring() + " elemenata"; //n elemenata void SumaNiza(int[] x, int n) int j, s; for (j = 0, s = 0; j < n; j++) s += x[j]; textbox2.text += "Suma elemenata niza je " + s + "\r\n"; 5

void SrednjaVrednost(int[] x, int n) int j; float xsr; for (j = 0, xsr = 0; j < n; j++) xsr += x[j]; xsr /= n; textbox2.text += "Srednja vrednost niza je " + xsr + "\r\n"; void SumaParnih(int[] x, int n) int j, sp; for (j = 0, sp = 0; j < n; j++) if (x[j] % 2 == 0) sp += x[j]; textbox2.text += "Suma parnih elemenata niza je " + sp + "\r\n"; void BrojNegativnih(int[] x, int n) int j, brneg; for (j = 0, brneg = 0; j < n; j++) if (x[j] < 0) brneg++; textbox2.text += "Broj negativnih elemenata je " + brneg + "\r\n"; void BrojDeljSa5(int[] x, int n) int j, b5; for (j = 0, b5 = 0; j < n; j++) if (x[j] % 5 == 0) b5++; textbox2.text += "Broj elemenata deljivih sa 5 je " + b5 + "\r\n"; void MaxNiza(int[] x, int n) int j, max = int.minvalue;; for (j = 0; j < n; j++) if (x[j] > max) max = x[j]; textbox2.text += "Maksimalni element niza je " + max + "\r\n"; void Sortiran(int[] x, int n) int i, j, pom; for (i = 0; i < n - 1; i++) for (j = i + 1; j < n; j++) if (x[i] > x[j]) pom = x[i]; x[i] = x[j]; x[j] = pom; for (i = 0; i < n; i++) listbox2.items.add(x[i].tostring()); private void button3_click(object sender, EventArgs e) textbox2.text = ""; if (checkbox1.checked) SumaNiza(x, n); if (checkbox2.checked) SrednjaVrednost(x, n); if (checkbox3.checked) SumaParnih(x, n); if (checkbox4.checked) BrojDeljSa5(x, n); if (checkbox5.checked) MaxNiza(x, n); if (checkbox6.checked) BrojNegativnih(x, n); if (checkbox7.checked) Sortiran(x, n); 6

7. zad namespace BUBBLE SORT public partial class Form1 : Form public Form1() InitializeComponent(); int[] x=new int[40]; int n=0,i=0; void SelectionSort(int[] x, int n) listbox2.items.clear(); int i, j, pom; for (i = 0; i < n - 1; i++) for (j = i + 1; j < n; j++) if (x[i] > x[j]) pom = x[i]; x[i] = x[j]; x[j] = pom; for (i = 0; i < n; i++) listbox2.items.add(x[i].tostring()); void BubbleSort(int[] x, int n) listbox2.items.clear(); int i, j, pom; do j=0;//nema promena for (i = 0; i < n - 1; i++) if (x[i] < x[i+1]) pom = x[i]; x[i] = x[i+1]; x[i+1] = pom; j=1;// bilo je promena while (j!=0); for (i = 0; i < n; i++) listbox2.items.add(x[i].tostring()); x[i] = Convert.ToInt32(textBox1.Text); //unesi x listbox1.items.add("x[" + i + "]=" + x[i]); i++; listbox1.text = "x[" + i + "]="; //priprema za sledeci textbox1.text = ""; n = i; SelectionSort(x, n); private void button3_click(object sender, EventArgs e) BubbleSort(x, n); 7