|
Toshkent – 2023 1-Tajriba ishi Malumotlarning oddiy sozlangan turlari
|
Sana | 10.01.2024 | Hajmi | 226,15 Kb. | | #134014 |
Bog'liq NizomovMTA amaliy
MUHAMMAD AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
Malumotlar tuzilmasi va algoritmlari fanidan
1-2-3 – Amaliy topshiriqlar
Bajardi:Nizomov Vali
Tekshirdi : Bo`riyev Yusuf
Toshkent – 2023
1-Tajriba ishi
Malumotlarning oddiy sozlangan turlari
22-variant
22.Сатрли типдаги вектор берилган. Бир хил қийматдаги элементларни аниқланг,
экранга чиқаринг.
Kodi:
#include
#include
#include
using namespace std ;
int main() {
vector myVector = {"olma", "apelsin", "banan", "olma", "uzum", "banan", "kiwi", "apelsin"};
unordered_map> occurrences;
for (int i = 0; i < myVector.size(); ++i) {
string currentString = myVector[i];
if (occurrences.find(currentString) == occurrences.end()) {
occurrences[currentString] = {i};
} else {
occurrences[currentString].push_back(i);
}
}
for (const auto& entry : occurrences) {
const string& value = entry.first;
const vector& indices = entry.second;
if (indices.size() > 1) {
cout << "Element qiymati bilan '" << value << "': ";
for (int index : indices) {
cout << "Index " << index << ", "; }
cout << endl; } }
return 0;
}
2-Tajriba ishi
QIDIRUV USULLARINI TADQIQ QILISH
Topshiriq:
22.Massivdan boshiga qo‘yish usuli yordamida key kalitli elementni izlash dasturini tuzing.
Kodi:
#include
using namespace std ;
int main() {
int myArray[] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
int size = sizeof(myArray) / sizeof(myArray[0]);
int key;
cout << "kalitni kiriting: ";
cin >> key;
int index = -1;
for (int i = 0; i < size; ++i) {
if (myArray[i] == key) {
index = i;
break;
}
}
if (index != -1) {
cout << "kalitga teng element " << key << " indexda topildi " << index << endl;
} else {
cout << "kalitga teng element " << key << " indexda topilmadi" << endl;
}
return 0;
}
3-Tajriba ishi
MA’LUMOTLARNI SARALASH USULLARINI TADQIQ QILISH
Topshiriq:
22.A massiv elementlari qiymatlarini kamayish tartibida saralash dasturini tuzing.
Kodi:
#include
#include
using namespace std ;
int main() {
int A[] = {5, 2, 8, 1, 7, 3, 9, 4, 6};
int size = sizeof(A) / sizeof(A[0]);
sort(A, A + size, greater());
cout << "Kamayish tartibida saralangan Massiv: ";
for (int i = 0; i < size; ++i) {
cout << A[i] << " ";
}
cout << endl;
return 0;
}
|
| |