1-topshiriq to’g’ri burchakli uchburchakning a va


Download 49.33 Kb.
bet8/17
Sana21.04.2023
Hajmi49.33 Kb.
#1373416
1   ...   4   5   6   7   8   9   10   11   ...   17
Bog'liq
dasturlash

N ta haqiqiy sonli ketma-ketlik berilgan. (ListBoxda). Ularning ichida K dan kichik, K ga teng va K dan katta sonlar qanchaligini aniqlang. Natija 3 ta Labelda chop etilsin

if (textBox1->Text != "")
{
//MessageBox::Show('Natija yuq', 'Xato',
MessageBoxButtons::OK, MessageBoxDefaultButton::"Error");
int k, a = 0, b = 0, c = 0;
k = Convert::ToInt16(textBox1->Text);
for (int i = 0; i < listBox1->Items->Count; i++)
{
if (Convert::ToInt16(listBox1->Items[i]) > k)
{
a++;
label4->Text = "K dan Katta: " +
Convert::ToString(a);
}
if (Convert::ToInt16(listBox1->Items[i]) < k)
{
c++;
label2->Text = "K dan Kichik: " +
Convert::ToString(c);
}
if (Convert::ToInt16(listBox1->Items[i]) == k)
{
b++;
label3->Text = "K ga Teng: " +
Convert::ToString(b);
}
}
}
Random ^n = gcnew Random();
for (int i = 0; i < 25; i++)
{
listBox1->Items->Add(Convert::ToString(n->Next(1, 100)));
}

17. 10 ta noutbuk nomi va narxlari 2 ta ListBoxda yozilgan. Qaysi noutbuk eng qimmat
ekanligini chop eting (Labelda).

  1. 10 ta talaba nomi va GPA ballari 2 ta ListBoxda yozilgan. Qaysi talabalar kursdan kurs o’tishini ListBoxda chop eting.

for (int i = 0; i < listBox2->Items->Count; i++)
{
if (Convert::ToDouble(listBox2->Items[i]) >= 2.6) {
listBox3->Items->Add(listBox1->Items[i]);
}
}
}
private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^
e) {
Random ^n = gcnew Random();
for (int i = 0; i < 14; i++)
{
listBox2->Items->Add(Convert::ToString(n->Next(0, 5)));
}


  1. 10 ta Xodim va olgan maoshi 2 ta ListBoxda yozilgan. Qaysi Xodim eng ko’p maosh olganini Labelda chop eting.

int max = Convert::ToInt32(listBox2->Items[0]);
int x = 0;
for (int i = 1; i < listBox2->Items->Count; i++) {
if (Convert::ToInt32(listBox2->Items[i]) > max) {
max = Convert::ToInt32(listBox2->Items[i]);
x = i;
}}
label1->Text = "Naija: " + listBox1->Items[x];


Download 49.33 Kb.

Do'stlaringiz bilan baham:
1   ...   4   5   6   7   8   9   10   11   ...   17




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