Dasturiy injinering


Download 472.01 Kb.
Sana18.06.2023
Hajmi472.01 Kb.
#1561255
Bog'liq
Diyorbek Xazratqulov (2)




MUHAMMAD AL-XORAZMIY
NOMIDAGI TOSHKENT AXBOROT
TEXNOLOGIYALARI
UNIVERSITETI “DASTURIY
INJINERING” FAKULTETI SWD007-3
GURUH TALABASI
XAZRATQULOV DIYORBEKNING
“DASTURLASH-II” FANIDAN
BAJARGAN 2-AMALIY
TOPSHIRIG’IGA JAVOBI

O’QITUVCHI: Mirzayeva Gulmira


13-variant

  1. Berilgan string turidagi to’plamning katta harfdan iborat elementlarini kichik harfga o’girib, 2- to’plamni va kichik harfdan iborat elementlarini katta harfga o’girib, 3- to’plamni hosil qiluvchi hamda ularni ekranga chiqaruvchi dastur tuzing.:

#include
#include
#include
#include
using namespace std;

int main() {

string input_str = "Mana bu Yerga kiritilgan matndan katta va kichiklarni achratib OLADI";

set uppercase_set;


for_each(input_str.begin(), input_str.end(), [&uppercase_set](char c) {
if (isupper(c)) {
uppercase_set.insert(tolower(c));
}
});

set lowercase_set;


for_each(input_str.begin(), input_str.end(), [&lowercase_set](char c) {
if (islower(c)) {
lowercase_set.insert(toupper(c));
}
});

set unique_set(input_str.begin(), input_str.end());


cout << "Kattaharfli set:";


for (char c : uppercase_set) {
cout << " " << c;
}
cout <cout << "Kichikharfli set:";


for (char c : lowercase_set) {cout << " " << c;
}
cout <cout << "Birlashgan set:";


for (char c : unique_set) {
cout << " " << c;
}
cout << endl;

return 0;


}
Natija:



2 Avtomobillar haqida (nomi, yili, versiyasi va narxi) to’plam berilgan. Avtomobillarni nomi, yili, versiyasi va narxi bo’yicha qidiruvchi hamda topilgan natijani faylga saqlashni taklif qiladigan dastur tuzing.
#include
#include
#include
#include

using namespace std;

struct Car {
string name;
int year;
string version;
int price;
};

int main() {

map cars;

cars["Nexia"] = {"Nexia", 2012, "R2", 7000};


cars["Cobalt"] = {"Cobalt", 2015, "LTZ1", 12000};
cars["Malibu"] = {"Malibu", 2019, "premier", 35000};

string name, version;


int year, price;
cout << "Mashina nomini kiriting yoki -1 orqali o'tkazib yuboring: ";
getline(cin, name);
cout << "Mashina yilini kiriting yoki -1 orqali o'tkazib yuboring: ";
cin >> year;
cout << "Mashina pzitsiyasini kiriting yoki -1 orqali o'tkazib yuboring: ";
cin.ignore();
getline(cin, version);
cout << "Mashina narxini kiriting yoki -1 orqali o'tkazib yuboring: ";
cin >> price;

map::iterator it;


bool found = false;
for (it = cars.begin(); it != cars.end(); ++it) {
Car car = it->second;
if ((name.empty() || car.name == name) &&
(year == -1 || car.year == year) &&
(version.empty() || car.version == version) &&
(price == -1 || car.price == price)) {
cout << "Mashinani topish: " << car.name << ", " << car.year << ", " << car.version << ", $" << car.price << endl;
found = true;
}
}

if (!found) {


cout << "MAshina topilmadi." << endl;
}

// Prompt the user to save the search result to a file


cout << "Qidiruv natijasini faylga saqlaysizmi? (h/y): ";
char choice;
cin >> choice;
if (choice == 'h') {
string filename;
cout << "Fayl nomini kiriting: ";
cin.ignore();
getline(cin, filename);
ofstream outfile(filename);
for (it = cars.begin(); it != cars.end(); ++it) {
Car car = it->second;
if ((name.empty() || car.name == name) &&
(year == -1 || car.year == year) &&
(version.empty() || car.version == version) &&
(price == -1 || car.price == price)) {
outfile << car.name << "," << car.year << "," << car.version << "," << car.price << endl;
}
}
outfile.close();
cout << "Qidiruv natijasi saqlandi" << filename << "." << endl;
}

return 0;


}
Natija:

Download 472.01 Kb.

Do'stlaringiz bilan baham:




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