Swd010-2 guruh talabasi Boboyev Hakimjonning dasturlash fanidan bajargan 2


Download 131.69 Kb.
Sana01.05.2023
Hajmi131.69 Kb.
#1418897

Toshkent axborot texnologiyalari universiteti Telekommunikatsiya texnologiyalari fakulteti SWD010-2 guruh talabasi Boboyev Hakimjonning dasturlash fanidan bajargan 2-shaxsiy topshirig’i


#include


#include
#include
#include
#include
using namespace std;
const int n = 3;
array Brendi;
array Rusumi;
array Rangi;
array Made_in;
array Ot_kuchi;
array Yili;
class Avto {
string brendi;
string rusumi;
string rangi;
string made_in;
float ot_kuchi;
int yili;

public:
void set(string B, string R, string Cl, string M, float O, int Y) {


static int i = 0;
Brendi[i] = B;
Rusumi[i] = R;
Rangi[i] = Cl;
Made_in[i] = M;
Ot_kuchi[i] = O;
Yili[i] = Y;

brendi = B;


rusumi = R;
rangi = Cl;
made_in = M;
ot_kuchi = O;
yili = Y;
i++;
}

void get() {


cout << "Brendi: " << brendi << endl;
cout << "Rusumi: " << rusumi << endl;
cout << "Rangi: " << rangi << endl;
cout << "Made in " << made_in << endl;
cout << "Ot kuchi: " << ot_kuchi << endl;
cout << "Yili: " << yili << endl;
}

void show(array &A) {


for (int i = 0; i < n; i++)
{
cout << i + 1 << "-Avtomobil ma'lumotlari" << endl;
A[i].get();
}
}

void jadvalSaralash(array& A,int y) {


cout << "Brendi\tRusumi\tRangi\tMade_in\tOt_kuchi\tYili\t\n";
for (int i = 0; i < n; i++)
{
if (A[i].yili >= y) {
cout << A[i].brendi << "\t";
cout << A[i].rusumi << "\t";
cout << A[i].rangi << "\t";
cout << A[i].made_in << "\t";
cout << A[i].ot_kuchi << "\t";
cout << A[i].yili << "\t\n";
}
}
}

void setAvto(array &A) {


string B, R, Cl, M; float O; int Y;
for (int i = 0; i < n; i++)
{

cout << i + 1 << "-avtomobil ma'lumotlarini kiriting:" << endl;


cout << "Avtomobil brendini kiriting: "; cin >> B; cin.ignore();
cout << "Avtomobil rusumini kiriting: "; cin >> R;
cout << "Avtomobil rangini kiriting: "; cin >> Cl;
cout << "Ishlab chiqargan davlatni kiriting: "; cin >> M;
cout << "Avtomobilning ot kuchini kiriting: "; cin >> O;
cout << "Avtomobilning yilini kiriting: "; cin >> Y;

A[i].set(B,R,Cl,M,O,Y);


}
}
};

int main() {


Avto avto;
array A;
avto.setAvto(A);
avto.show(A);
int y;
cout << "Qaysi yildan yuqori avtomobil izlayapsiz:"; cin >> y;
avto.jadvalSaralash(A, y);

}



#include
#include

using namespace std;


// Elementni o'chirish funksiyasi


void removeElement(vector& v, int index) {
for (int i = 0; i {
v.erase(v.begin());
}
}

int main() {


int index, n,q;
vector v;
cout << "Vector elementlari sonini kiriting:"; cin >> n;
for (int i = 0; i < n; i++)
{
cin >> q;
v.push_back(q);
}

cout << "Vectorning indexini kiriting:"; cin >> index;


removeElement(v, index);


// Vectorning joriy holatini chiqaramiz


for (int i = 0; i < v.size(); i++) {
cout << v[i] << " ";
}
cout << endl;

return 0;


}

#include
#include
using namespace std;

void printElement(string A, int index1, int index2) {


if (index1 >= A.length() || index2 >= A.length() || index1 < 0 || index2 < 0) {
cout << "Bunday element mavjud emas" << endl;
return;
}
cout << A.substr(index1, index2-index1+1) << endl;
}

int main() {


string Toplam = "Bu C++ dasturlash tilida matnli ishni oʻz ichiga olgan dasturlash tillari orasida oʻrni oʻzida egallaydi.";
char *A = new char[Toplam.length()];

for (int i = 0; i < Toplam.length(); i++) {


A[i] = Toplam[i];
}

printElement(Toplam, 3, 13);


printElement(Toplam, 58, 67);
printElement(Toplam, 0, 103);
printElement(Toplam, 100, 105);

return 0;


}



#include


#include

using namespace std;


int main() {


vectorZ = { 2, -3, 5, -7, 8, -12, 6, -4, 9 };
vectorB = { 1, 4, 6, 3, 7, 5, 9, 11, 2 };

cout << "B to'plam elementlari: " << endl;
for (int i=0; i< B.size();i++)
{
cout << B.at(i) << " ";
}

for (int i = 0; i < Z.size(); i++)


{
if (Z.at(i) < 0 && Z.at(i) % 2 == 0) {
for (int j = 0; j < B.size(); j++)
{
if (B.at(j) > 0 && B.at(j) % 2 != 0) {
B.insert(B.begin() + 1,Z.at(i));
break;
}
}
}
}
cout << "\n";
cout << "Keyingi B to'plam elementlari: " << endl;
for (int i = 0; i < B.size(); i++)
{
cout << B.at(i) << " ";
}

return 0;


}

Download 131.69 Kb.

Do'stlaringiz bilan baham:




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