Witam Serdecznie
Mam problem z posortowaniem rosnącym za pomocą lambdy , malejące sortowanie mi dziala lecz rosnace juz nie bardzo wyswietlaja sie zera czyzbym przy wyswietlaniu cos zepsul ? nie mam szczerze pojecia co zle robie analizowalem to lecz pewnie moje umiejtnosci sa za male a raczej powiedzial bym 2/10 w załaczniku znajduje sie moj program i napisane gdzie cos nie dziala,dziekuje za pomoc. Jestem nowym uzytkownikiem i przepraszam jesli to co napisalem jest za bardzo banalne aby wstawiac tutaj na forum.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LabIIV
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public delegate int poteguj(int x);
public delegate int dodaj(int x, int y, int z);
int[] tab = new int[100];
int i = 0;
private void Form1_Load(object sender, EventArgs e)
{
}
public void Pote()
{
poteguj pw = (x) => { return x * x * x; };
textBox4.Text = (pw(System.Int32.Parse(textBox1.Text))).ToString();
}
public void Dodawanie()
{
dodaj suma = (x,y,z) => { return x + y + z; };
textBox4.Text = (suma(System.Int32.Parse(textBox1.Text), System.Int32.Parse(textBox2.Text), System.Int32.Parse(textBox3.Text))).ToString();
}
public void SortujMalejaco(int[] tab)
{
Comparison<int> mal;
mal = (int a, int b) => b - a;
Array.Sort(tab, mal);
}
/* public void SortujRosnaco(int[]tab)
{
Comparison<int> ros;
// ros = (int a, int b) => a - b;
Array.Sort(tab, ros);
*/
}
private void button1_Click(object sender, EventArgs e)
{
if (checkBox1.Checked && checkBox2.Checked == false)
{
Pote();
textBox1.Text = " ";
textBox2.Text = " ";
textBox3.Text = " ";
}
if (checkBox2.Checked && checkBox1.Checked == false)
{
Dodawanie();
textBox1.Text = " ";
textBox2.Text = " ";
textBox3.Text = " ";
}
}
private void button2_Click_1(object sender, EventArgs e)
{
SortujMalejaco(tab);
textBox5.Text = " ";
for (int l = 0; l < i; l++)
{
textBox5.AppendText(tab[l].ToString() + "\n");
}
}
private void button3_Click(object sender, EventArgs e)
{
textBox4.Text = " ";
tab[i] = System.Int32.Parse(textBox6.Text);
textBox5.Text = " ";
for (int l = 0; l <= i; l++)
{
textBox5.AppendText(tab[l].ToString() + "\n");
}
i++;
}
private void Form1_Load_1(object sender, EventArgs e)
{
}
/* private void button4_Click(object sender, EventArgs e)
{
SortujRosnaco(tab);
textBox5.Text = " ";
for (int l = 0; l < i; l++)
{
textBox5.AppendText(tab[l].ToString() + "\n") ;
*/}
}
}
}