19 April 2023
D I
#include <iostream>
#include <set>
#include <string>
int main() {
std::set<std::string> evenLengthSet;
std::multiset<std::string> oddLengthSet;
std::multiset<std::string> allSet;
// Juft uzunlikdagi elementdan iborat to'plamni yaratish
std::string evenLengthArray[] = {"one", "two", "three", "four", "five", "six"};
int evenLengthArraySize = sizeof(evenLengthArray) / sizeof(evenLengthArray[0]);
// Juft uzunlikdagi elementlarni to'plamga qo'shish
for (int i = 0; i < evenLengthArraySize; ++i) {
if (evenLengthArray[i].length() % 2 == 0) {
evenLengthSet.insert(evenLengthArray[i]);
}
}
// Toq uzunlikdagi elementdan iborat to'plamni yaratish
std::string oddLengthArray[] = {"apple", "banana", "orange", "pear", "kiwi"};
int oddLengthArraySize = sizeof(oddLengthArray) / sizeof(oddLengthArray[0]);
// Toq uzunlikdagi elementlarni to'plamga qo'shish
for (int i = 0; i < oddLengthArraySize; ++i) {
if (oddLengthArray[i].length() % 2 != 0) {
oddLengthSet.insert(oddLengthArray[i]);
}
}
// Barcha elementlarni bir to'plamga qo'shish
allSet.insert(evenLengthSet.begin(), evenLengthSet.end());
allSet.insert(oddLengthSet.begin(), oddLengthSet.end());
// Ikki to'plamdan ham bir xil qiymatli elementlarni o'chirib tashlash
for (std::string s : evenLengthSet) {
oddLengthSet.erase(s);
allSet.erase(s);
}
// Hosil qilingan to'plamlarni ekranga chiqarish
std::cout << "Even Length Set: ";
for (std::string s : evenLengthSet) {
std::cout << s << " ";
}
std::cout << std::endl;
std::cout << "Odd Length Set: ";
for (std::string s : oddLengthSet) {
std::cout << s << " ";
}
std::cout << std::endl;
std::cout << "All Set: ";
for (std::string s : allSet) {
std::cout << s << " ";
}
std
#include <iostream>
using namespace std;
int main() {
const int width = 10;
const int height = 6;
for (int row = 1; row <= height / 2; ++row) {
for (int col = 1; col <= (height - row); ++col) {
cout << " ";
}
for (int col = 1; col <= (2 * row - 1); ++col) {
if (col == 1 || col == (2 * row - 1)) {
cout << "/";
} else {
cout << " ";
}
}
cout << endl;
}
for (int row = height / 2 + 1; row <= height; ++row) {
for (int col = 1; col <= (row - 1); ++col) {
cout << " ";
}
for (int col = 1; col <= (2 * height - 2 * row + 1); ++col) {
if (col == 1 || col == (2 * height - 2 * row + 1)) {
cout << "\\";
} else {
cout << " ";
}
}
cout << endl;
}
for (int row = 1; row <= height; ++row) {
for (int col = 1; col <= width; ++col) {
if (col == 1 || col == width) {
cout << "|";
} else {
cout << " ";
}
}
cout << endl;
}
return 0;
}