1-Amaliy topshirig`i 1-Topshiriq


Download 0.54 Mb.
Sana25.01.2023
Hajmi0.54 Mb.
#1123276
Bog'liq
Barchinoy amaliy ish


Mirzo Ulug`bek nomidagi
O`zbekiston Milliy Universiteti
Jizzax filiali Amaliy Amtematika
yo`nalishi 02-21-guruh talabasi
Jabborova Barchinoyning
Algoritmik tillar va dasturlash fanidan
1-Amaliy topshirig`i

1-Topshiriq
11. Chapga siklik siljishni amalga oshiruvchi ShiftLeft3(A,B,C) funksiyasini hosil qiling. Ya’ni C ning qiymati B ga, B ning qiymati A ga, A niki esa C ga o’tib qolsin. Bu funksiya orqali (A1,B1,C1) va (A2,B2,C2) sonlarni siljiting.
1.Anonim metodda bajarish:

namespace WindowsFormsApp13


{
public delegate void Almashtirish(int A1, int B1, int C1);
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void textBox2_TextChanged(object sender, EventArgs e)


{

}


private void Form1_Load(object sender, EventArgs e)
{

}


private void button1_Click(object sender, EventArgs e)
{
Almashtirish h = delegate (int A1, int B1, int C1)
{
int temp = A1;
A1 = B1;
B1 = C1;
C1 = temp;
richTextBox1.Text = Convert.ToString(A1 + " " + B1 + " " + C1);
};
int S = int.Parse(textBox1.Text);
int F = int.Parse(textBox2.Text);
int L = int.Parse(textBox3.Text);
h(S, F, L);
}

}
}


Func da bajarish:
delegate void Almashtirish(int A1, int B1, int C1);
public partial class Form1 : Form
{
public int ShiftLeft3(int A1,int B1,int C1)
{
int temp = A1;
A1 = B1;
B1 = C1;
C1 = temp;
richTextBox1.Text = Convert.ToString(A1 + " " + B1 + " " + C1);
return 0;
}
public Form1()
{
InitializeComponent();
}

private void textBox2_TextChanged(object sender, EventArgs e)


{

}


private void Form1_Load(object sender, EventArgs e)
{

}


private void button1_Click(object sender, EventArgs e)
{
int A1=int.Parse(textBox1.Text);
int B1 = int.Parse(textBox2.Text);
int C1 = int.Parse(textBox3.Text);
Func func = ShiftLeft3;
func.Invoke(A1, B1, C1);

}


}
}



3.Action bilan ishlash:

delegate void Almashtirish(int A1, int B1, int C1);


public partial class Form1 : Form
{
public void ShiftLeft3(int A1,int B1,int C1)
{
int temp = A1;
A1 = B1;
B1 = C1;
C1 = temp;
richTextBox1.Text = Convert.ToString(A1 + " " + B1 + " " + C1);
}
public Form1()
{
InitializeComponent();
}

private void textBox2_TextChanged(object sender, EventArgs e)


{

}


private void Form1_Load(object sender, EventArgs e)
{

}


private void button1_Click(object sender, EventArgs e)
{
int A1=int.Parse(textBox1.Text);
int B1 = int.Parse(textBox2.Text);
int C1 = int.Parse(textBox3.Text);
Action Left = ShiftLeft3;
Left.Invoke(A1, B1, C1);

}


}
}

4.Delegatlar bilan ishlash:

delegate void Almashtirish(int A1, int B1, int C1);


public partial class Form1 : Form
{
public void ShiftLeft3(int A1,int B1,int C1)
{
int temp = A1;
A1 = B1;
B1 = C1;
C1 = temp;
richTextBox1.Text = Convert.ToString(A1 + " " + B1 + " " + C1);
}
public Form1()
{
InitializeComponent();
}

private void textBox2_TextChanged(object sender, EventArgs e)


{

}


private void Form1_Load(object sender, EventArgs e)
{

}


private void button1_Click(object sender, EventArgs e)
{
int A1=int.Parse(textBox1.Text);
int B1 = int.Parse(textBox2.Text);
int C1 = int.Parse(textBox3.Text);
Almashtirish son = new Almashtirish(ShiftLeft3);
son.Invoke(A1, B1, C1);

}


}
}

Download 0.54 Mb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling