Topshiriq 16-variant


Download 0.58 Mb.
Sana09.11.2023
Hajmi0.58 Mb.
#1760457
Bog'liq
Dilshoda Algoritm topshiriq1


Topshiriq
16-variant

  1. Markazi bir nuqtada bo’lgan, R1 va R2 radiusga ega 2 ta aylananing ustma-ust tushmaydigan (kesishmaydigan) qismining yuzasini topuvchi RingS nomli funksiya


Ananim Metod
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 WindowsFormsApplication20


{
//delegat e'lon qilish
public delegate int Degree(int i);
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
//o'zgaruvchilarni kiritish
int R1 = int.Parse(textBox1.Text);
int R2 = int.Parse(textBox2.Text);
double s = (double)Math.PI * (double)(Math.Pow(R2, 2) - Math.Pow(R1, 2));
richTextBox1.Text += Convert.ToString("Yuza S=" + d((int)s) + "\n");
}
//delegatdan obyekt hosil qilib unga anonim metod tayinlash
Degree d = delegate(int S)
{
return S;
};
}
}




Func
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 WindowsFormsApplication20


{
//delegat e'lon qilish
//public delegate int Degree(int i);
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
//Func////////////////////////////////
//delegatga metod tayinlash
Func add = Summ;

//o'zgaruvchilarni kiritish


int R1 = int.Parse(textBox1.Text);
int R2 = int.Parse(textBox2.Text);
//delegatni ishlatish va natijani o'zlashtirish
int result = add(R1, R2);
richTextBox1.Text += Convert.ToString("Yuza S="+result+"\n");
}
//natijani qaytaruvchi metod
static int Summ(int R1, int R2)
{
double s = (double)Math.PI * (double)(Math.Pow(R2, 2) - Math.Pow(R1, 2));
return (int)s;
}

private void textBox2_TextChanged(object sender, EventArgs e)


{

}
}
}




Action
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 WindowsFormsApplication20


{
//delegat e'lon qilish
//public delegate int Degree(int i);
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// public delegate void Print(int );
private void button1_Click(object sender, EventArgs e)
{

//o'zgaruvchilarni kiritish


int R1 = int.Parse(textBox1.Text);
int R2 = int.Parse(textBox2.Text);
double s = (double)Math.PI * (double)(Math.Pow(R2, 2) - Math.Pow(R1, 2));
richTextBox1.Text += Convert.ToString("Yuza S=" + (int)s + "\n");
}

private void ConsolePrint(int obj)


{
throw new NotImplementedException();
}
//natijani qaytaruvchi metoda
public static void ConsolePrint(int R1,int R2)
{
Action printActionDel = delegate(int s)
{
double S = (double)Math.PI * (double)(Math.Pow(R2, 2) - Math.Pow(R1, 2));
};

}


}
}


Download 0.58 Mb.

Do'stlaringiz bilan baham:




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