Using System; using


Download 77.94 Kb.
Sana03.02.2023
Hajmi77.94 Kb.
#1154030
Bog'liq
aHMADJONOV


Tuzuvchi:Ahmadjonov Javlonbek



5-Raqam:
2-masala: Guruh nomli (ID, Nomi, YunalishNomi, TalabaSoni maydonlarga ega) class yarating. 5 ta guruhdan iborat ro’yxat tuzing. Ro’yxatni TalabaSoni bo’yicha saralab chiqaruvchi dastur tuzing.
Masalaning C#dagi matni:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Linq;

namespace aHMADJONOV
{
class Gurx
{
public int ID{get;set;}
public string Nomi{get;set;}
public string Yunalishnomi{get;set;}
public int Talabasoni{get;set;}
}

public partial class MainForm : Form
{
public MainForm()
{

InitializeComponent();
List guruh=new List();
guruh.Add(new Gurx{ID=1,Nomi="21.06-guruh",Yunalishnomi="Amaliy matematika",Talabasoni=21});
guruh.Add(new Gurx{ID=2,Nomi="21.07-guruh",Yunalishnomi="Amaliy matematika",Talabasoni=23});
guruh.Add(new Gurx{ID=3,Nomi="21.08-guruh",Yunalishnomi="Amaliy matematika",Talabasoni=22});
guruh.Add(new Gurx{ID=4,Nomi="21.09-guruh",Yunalishnomi="Fizika",Talabasoni=26});
guruh.Add(new Gurx{ID=5,Nomi="21.10-guruh",Yunalishnomi="Fizika",Talabasoni=26});
var sorov=
from b in guruh
where b.ID>0 
select b;
label1.Text="Birinchi ro'yxat:\n";
foreach (var c in sorov)
label1.Text+=c.ID+"."+c.Nomi+"."+c.Yunalishnomi+"."+c.Talabasoni+"ta"+"\n";
label2.Text="Keyingi ro'yxat:\n";
var sorov1=
from e in guruh
where e.Talabasoni>0
orderby e.Talabasoni
select e;
foreach (var f in sorov1)
label2.Text+=f.ID+"."+f.Nomi+"."+f.Talabasoni+"ta"+"\n";
}
}
}

Natija:


1-masala: Berilgan S satrdagi katta xarflar sonini qaytaruvchi KattaXarfSoni(S) metodini yarating. Delegat yordamida metoddan foydalanib katta xarflar sonini chiqaruvchi dastur tuzing.
Masalaning C#dagi matni:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

namespace sdsadsa
{
/// <summary>
/// Description of MainForm.
/// </summary>
/// 
delegate int trigonometriy (string arr);
public partial class MainForm : Form
{
public MainForm()
{

InitializeComponent();
label1.Text="S matnni kiriting";
label2.Text="";
button1.Text="Natija";

}
void Button1Click(object sender, EventArgs e)


{
string S=textBox1.Text;
trigonometriy w=new trigonometriy(ENGKATTAXARF);
label2.Text=w(S).ToString();
}
public int ENGKATTAXARF(string S)
{
int count =0;
for (char A='A';A<='Z';A++)
{
for(int i=0;i{
if(S[i]==A) count++;
}
}
return count;
}
}
}
Natija:

Download 77.94 Kb.

Do'stlaringiz bilan baham:




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