#include using namespace std; int main { vector numbers = {5, 3, -2, 10, 8, 1, 0, -7}; int max number = numbers[0]; int index of max number = 0; for (int i = 1; i < numbers size; i++) { if


Download 0.49 Mb.
Sana16.06.2023
Hajmi0.49 Mb.
#1488759
Bog'liq
Sevda A3


O`ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI


MUHAMMAD AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI
UNIVERSITETI

“AKT sohasida kasb ta’limi” yo’nalishi


651-22 guruh talabasi
HAYITBOYEVA SEVDAning
DASTURLASH 2” fanidan tayyorlagan

3-Amaliy ishi

O’qituvchi:

Shabdorov Elbek

1-Topshiriq.
21-Variant
6.Navbat eng katta elementi topilsin va undan keyin 0 joylashtirilsin.

Kodi:
#include
#include

using namespace std;

int main() {
vector numbers = {5, 3, -2, 10, 8, 1, 0, -7};
int max_number = numbers[0];
int index_of_max_number = 0;

for (int i = 1; i < numbers.size(); i++) {
if (numbers[i] >= max_number) {
max_number = numbers[i];
index_of_max_number = i;
}
}

numbers[index_of_max_number+1] = 0;

for (int number : numbers) {
cout << number << " ";
}

return 0;
}
Natijasi:





Kodi:
#include
#include
#include

using namespace std;

class Odamlar {
public:
string ism;
string familiya;
int yosh;
};

class Talabalar : public Odamlar {


public:
double bahosi;
};

int main() {


vector talabalar;

Talabalar talaba1;


talaba1.ism = "Ali";
talaba1.familiya = "Valiyev";
talaba1.yosh = 20;
talaba1.bahosi = 4.5;
talabalar.push_back(talaba1);

Talabalar talaba2;


talaba2.ism = "Nargiza";
talaba2.familiya = "Karimova";
talaba2.yosh = 19;
talaba2.bahosi = 3.8;
talabalar.push_back(talaba2);

Talabalar talaba3;


talaba3.ism = "Shohruh";
talaba3.familiya = "Abdullayev";
talaba3.yosh = 21;
talaba3.bahosi = 4.9;
talabalar.push_back(talaba3);

cout << "Talabalar ro'yxati:" << endl;


for (int i = 0; i < talabalar.size(); i++) {
cout << talabalar[i].ism << " " << talabalar[i].familiya << ", " << talabalar[i].yosh << " yosh, bahosi: " << talabalar[i].bahosi << endl;
}

return 0;


}

Natija:

Download 0.49 Mb.

Do'stlaringiz bilan baham:




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