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


dan gacha bo’lgan intervalda bo’linuvchilarning maksimal yig’indisi bo’lgan natural


Download 49.33 Kb.
bet6/17
Sana21.04.2023
Hajmi49.33 Kb.
#1373416
1   2   3   4   5   6   7   8   9   ...   17
Bog'liq
dasturlash

5. dan gacha bo’lgan intervalda bo’linuvchilarning maksimal yig’indisi bo’lgan natural
sonni toping. (2 ta Label, 2 ta TextBox, 1 ta Button. Natija Label chop etilsin)
int a, b, c = 0, natija;
a = Convert::ToInt32(textBox1->Text);
b = Convert::ToInt32(textBox2->Text);
for (int i = a; i <= b; i++) {
for (int j = 1; j <= i; j++) {
if (i%j == 0) {
c += j;
}}
this->listBox1->Items->Add(Convert::ToString(c));
c = 0;
}
natija = Convert::ToInt32(listBox1->Items[0]); int g = a;
for (int i = 1; i < listBox1->Items->Count; i++) {
if (natija < Convert::ToInt32(listBox1->Items[i])) {
natija = Convert::ToInt32(listBox1->Items[i]);
g = i;
}
}
this->label6->Text += " " + (a + g);

6. Manfiy bo’lmagan butun son berilgan. Uning o’nli yozuvidagi nollar sonini aniqlang.
Masalan, n=103062 uchun javob 2. (Ko’rsatma: 1 ta Label, 1 ta TextBox, 1ta Button.
Natija: Labelda chop etilsin)
7. Natural son berilgan. Undagi birinchi raqamiga teng bo’lgan raqam necha marta uchrashini aniqlang. (1 ta Label, 1 ta TextBox, 1 ta Button. Natija Labelda chop etilsin)

  1. 1 dan n gacha Fibonachchi sonlarni ListBoxga chiqaring. Uchinchidan boshlab Fibonachchi sonlar ketma-ketligining har biri oldingi ikkita sonlar yig’indisiga teng.

listBox1->Items->Clear();
int n, first = 0, second = 1, third = 0;
if (textBox1->Text->Length == 0) {
MessageBox::Show("son kiriting ", "Xatolik yuz berdi", MessageBoxButtons::OK, MessageBoxIcon::Error);
}
else
{n = Convert::ToInt64(textBox1->Text);
if (n == 0)
{
listBox1->Items->Add(first);
}
if (n >= 1)
{
listBox1->Items->Add(second);
}
for (int i = 0; i < n - 2; i++)
{
third = first + second;
listBox1->Items->Add(third);
first = second;
second = third;
}
}
9. n natural son berilgan. n soni Fibonachchi soni hisoblanishini aniqlang, ya’ni bu son 1, 1, 2, 3, 5, 8, 13, 21, 34, … ketma-ketlik elementi hisoblansa. (ListBoxga Fibonachchi sonlari bo’lsin, Natija Labelda chiqarilsin)


  1. Download 49.33 Kb.

    Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9   ...   17




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