Girilen Sayıları Büyükten Küçüğe Sıralama C#.NET(C.NET)…

[code=’Csharp’]
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Add(textBox1.Text);
textBox1.Text = “”;
}
private void button2_Click(object sender, EventArgs e)
{
int i, j, c;
for (i = 0; i <= listBox1.Items.Count - 1; i++)
for (j = i; j <= listBox1.Items.Count - 1; j++)
if (int.Parse(listBox1.Items[j].ToString()) >
int.Parse(listBox1.Items[i].ToString()))
{
c = int.Parse(listBox1.Items[i].ToString());
listBox1.Items[i] = listBox1.Items[j];
listBox1.Items[j] = c.ToString();
}
}
private void button3_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
int i;
Random r = new Random();
for (i = 1; i <= 20; i++)
listBox1.Items.Add(((int)r.Next(100)).ToString());
}
private void button4_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsDigit(e.KeyChar) == false && e.KeyChar != (char)08)
e.Handled = true;
}
private void button5_Click(object sender, EventArgs e)
{
int i;
DialogResult a;
a = MessageBox.Show(listBox1.SelectedIndices.Count.ToString() + "Silmek İstiyormusunuz?", "SİL", MessageBoxButtons.YesNo);
if (a == DialogResult.Yes)
for (i = listBox1.SelectedIndices.Count - 1; i >= 0; i–)
listBox1.Items.RemoveAt(listBox1.SelectedIndices[i]);
}
private void button6_Click(object sender, EventArgs e)
{
colorDialog1.ShowDialog();
textBox1.ForeColor = colorDialog1.Color;
}
private void button7_Click(object sender, EventArgs e)
{
fontDialog1.ShowDialog();
textBox1.Font = fontDialog1.Font;
}
private void button8_Click(object sender, EventArgs e)
{
int i, j, c;
for (i = 0; i <= listBox1.Items.Count - 1; i++)
for (j = i; j <= listBox1.Items.Count - 1; j++)
if (int.Parse(listBox1.Items[j].ToString()) <
int.Parse(listBox1.Items[i].ToString()))
{
c = int.Parse(listBox1.Items[i].ToString());
listBox1.Items[i] = listBox1.Items[j];
listBox1.Items[j] = c.ToString();
}
}
}
[/code]
teşekkürler admin eline sağlık
Arkadaşlar sizden bir konuyla ilgili yardım istiycektim.Benim performans ödevi için konuya ihtiyacım var ama oyun yapıcam.Aklınıza gelen bir oyun olursa ismini yazarsanız sevinirim.
Not;Yapıcağım ödev C#.Net!te olucak.
Şimdiden teşekkür ederim 🙂
Ya kardeşim kodlar calısıyor ama anlamadıgım bi nokta büyükten küçüğe sıralayla küçükten büyüğe sırlama kodları aynı kafam allak bullak oldu bi acıklama yaparmısın zahmet olmassa hacı cok lazım ya :/
Osman :
Tek bir karakter farkı var
if (int.Parse(listBox1.Items[j].ToString()) < int.Parse(listBox1.Items[i].ToString())) satırındaki < ve > işaret farkı var.