1 / 10

Elazığ, 2012

C#. Elazığ, 2012. Diziler – eleman giriş ve toplam. using giris = Microsoft. VisualBasic . Interaction ;. private void button1_Click(object sender, EventArgs e) { int [] x; x = new int [10]; int i,t=0; for (i = 0; i <= 9; i++) {

faye
Download Presentation

Elazığ, 2012

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. C# Elazığ, 2012

  2. Diziler – eleman giriş ve toplam usinggiris = Microsoft.VisualBasic.Interaction; private void button1_Click(object sender, EventArgs e) { int[] x; x = newint[10]; int i,t=0; for (i = 0; i <= 9; i++) { x[i] = int.Parse(giris.InputBox("x[" + i.ToString() + "]=", "Bilgi Girişi", " ", 0, 0)); listBox1.Items.Add("x[" + i.ToString() + "]=" + x[i].ToString()); t = t + x[i]; } MessageBox.Show(t.ToString()); }

  3. Inputbox çalıştırmak için usinggiris = Microsoft.VisualBasic.Interaction; Project/addreferences/microsoftVisualBasic

  4. Elemanlar toplanıyor private void button1_Click(object sender, EventArgs e) { int[] x = new int[] { 2, 0, 3, 4 }; int i, t = 0; for (i = 0; i <= 3; i++) t = t + x[i]; MessageBox.Show(t.ToString()); }

  5. Diziler – a[i]=i*i private void button1_Click(object sender, EventArgs e) { int[] x; x = newint[10]; int i; for (i = 0; i <= 9; i++) { x[i] = i * i; listBox1.Items.Add("x[" + i.ToString() + "]=" + x[i].ToString()); } } Açıklama : for(i = 0; i <= x.GetUpperBound(0) ; i++)

  6. Eleman topla ve tersden yazdır private void button1_Click(object sender, EventArgs e) { int[] x = new int[] { -2, 10, -3, 5 }; int i, t = 0; for (i = 0; i <= 3; i++) t = t + x[i]; MessageBox.Show(t.ToString()); for (i = 3; i >=0 ; i--) listBox1.Items.Add(x[i].ToString()) ; }

  7. En büyük eleman private void button1_Click(object sender, EventArgs e) { int[] x; x = newint[10]; inti,enb; listBox1.Items.Clear(); for (i = 0; i <= 9; i++) { x[i] = int.Parse(giris.InputBox("x[" + i.ToString() + "]=", "Bilgi Girişi", " ", 0, 0)); listBox1.Items.Add("x[" + i.ToString() + "]=" + x[i].ToString()); } enb = x[0]; for (i = 0; i <= 9; i++) if (x[i] > enb) enb = x[i]; MessageBox.Show(enb.ToString()); }

  8. Diziler a+b dizisi usinggiris = Microsoft.VisualBasic.Interaction; private void button1_Click(object sender, EventArgs e) { int[,] a = new int[3, 3]; int[,] b = new int[3, 3]; int[,] c = new int[3, 3]; int i, j; for(i=0;i<=2;i++) for (j = 0; j <= 2; j++) { a[i, j] = int.Parse(giris.InputBox("a["+i.ToString()+","+j.ToString()+"]=","Bilgi Girişi", " ", 0, 0)); b[i, j] = int.Parse(giris.InputBox("b[“+i.ToString()+",”+j.ToString() + "]=", "Bilgi Girişi", " ", 0, 0)); c[i, j] = a[i, j] + b[i, j]; listBox1.Items.Add("c["+i.ToString()+","+j.ToString()+"]="+c[i, j].ToString()); } }

  9. Dizinin elemanları toplanıyor private void button1_Click(object sender, EventArgs e) { int [,] x=newint [,] {{2,0,3,4},{-1,3,2,4},{0,6,7,-2},{5,3,-4,0}}; int i, j, t=0; for(i=0;i<=3;i++) for (j = 0; j <= 3; j++) { t = t + x[i, j]; } MessageBox.Show(t.ToString()); } int [,] x= {{2,0,3,4},{-1,3,2,4},{0,6,7,-2},{5,3,-4,0}}; boyut yazılmayabilir

  10. Uygulama Soruları • 1:erkek, 0:bayan olmak üzere diziye eleman giriliyor. 10 elemanlı dizideki bayan ve erkek sayısını bulan prog? • 3x3 lük bir dizinin elemanları giriliyor. Dizinin transpozunu alan prog? • 10 elemanlı dizinin elemanları giriliyor. Girilen limit bir sayıdan büyük olanların sayısını bulan prog?

More Related