uRasgele Sayıların Büyük Ve Küçük Sayıyı Gösterme Ve Sıralama — Csharp
[code lang=”csharp”]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;//www.gorselprogramlama.com
using System.Windows.Forms;
namespace Döngüler
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int[] rasgeleSayi = new int[10];
Random r = new Random();
private void btnRasgeleSayi_Click(object sender, EventArgs e)
{
lblRSayilar.Text = ""//www.gorselprogramlama.com
for (int i = 0; i <= 9; i++)
{
rasgeleSayi[i] = r.Next(100);
lblRSayilar.Text += rasgeleSayi[i] + "\n";
}
}
private void btnEnBuyuk_Click(object sender, EventArgs e)
{
int enBuyuk = rasgeleSayi[0];
for (int i = 1; i <=9; i++)
{
if (enBuyuk < rasgeleSayi[i])
{
enBuyuk = rasgeleSayi[i];//www.gorselprogramlama.com
}
lblEnBuyuk.Text = enBuyuk.ToString();
}
}
private void btnEnKucuk_Click(object sender, EventArgs e)
{
int enKucuk = rasgeleSayi[0];
for (int i = 1; i <= 9; i++)
{
if (enKucuk > rasgeleSayi[i])
{
enKucuk = rasgeleSayi[i];//www.gorselprogramlama.com
}
lblEnKucuk.Text = enKucuk.ToString();
}
}
private void btnBuyuktenKucuge_Click(object sender, EventArgs e)
{
int gecici;
lblBuyuktenKucuge.Text = "";
for (int i = 0; i <9; i++)// En büyüğü bulma döngüsü
{
for (int j = i+1; j <=9; j++)
{
if (rasgeleSayi[i] < rasgeleSayi[j])
{
gecici = rasgeleSayi[i];
rasgeleSayi[i] = rasgeleSayi[j];
rasgeleSayi[j] = gecici;
}
}
}
for (int i = 0; i <=9; i++) // Label’e yazdırma döngüsü
{
lblBuyuktenKucuge.Text += rasgeleSayi[i] + "\n";
}
}
}//www.gorselprogramlama.com
}
[/code]

