Написать программу, которая на вход получает 2 множества, а при выходе даёт 4 множества. можно на любом языке программирования. а ещё если не сложно , на псевдокоде.
Ответы на вопрос:
кроме c++ ничего не знаю.
g++ compiler
#include < iostream>
#include < algorithm>
#include < set>
#include < iterator>
int main()
{
std: : set< int>
set1,//первое входное множество(a)
set2,//второе выходное множество(b)
set3,//первое выходное(разность set1 и set2)
set4,//xz
set5,//a пересечение b
set6; //a объединение b
int
n, m,
temp;
std: : cout < < "введите размер первого и второго множеств: ";
std: : cin > > n > > m;
std: : cout < < std: : endl < < "введите значения первого множества: ";
for(int i = 0; i < n; i++)
{
std: : cin > > temp;
set1.insert(temp);
}
std: : cout < < std: : endl < < "введите значения второго множества: ";
for(int i = 0; i < m; i++)
{
std: : cin > > temp;
set2.insert(temp);
}
std: : set_difference(set1. set1. set2. set2. std: : inserter(set3, set3.;
std: : set_difference(set2. set2. set1. set1. std: : inserter(set4, set4.;
std: : set_intersection(set1. set1. set2. set2. std: : inserter(set5, set5.;
std: : set_union(set1. set1. set2. set2. std: : inserter(set6, set6.;
//вывод
std: : cout < < "множество а: ";
std: : copy(set1. set1.
std: : ostream_iterator< int> (std: : cout, " "));
std: : cout < < std: : endl;
std: : cout < < "множество b: ";
std: : copy(set2. set2.
std: : ostream_iterator< int> (std: : cout, " "));
std: : cout < < std: : endl;
std: : cout < < "множество а - b: ";
std: : copy(set3. set3.
std: : ostream_iterator< int> (std: : cout, " "));
std: : cout < < std: : endl;
std: : cout < < "множество b - a: ";
std: : copy(set4. set4.
std: : ostream_iterator< int> (std: : cout, " "));
std: : cout < < std: : endl;
std: : cout < < "множество a пересечение b: ";
std: : copy(set5. set5.
std: : ostream_iterator< int> (std: : cout, " "));
std: : cout < < std: : endl;
std: : cout < < "множество а объединение b: ";
std: : copy(set6. set6.
std: : ostream_iterator< int> (std: : cout, " "));
std: : cout < < std: : endl;
return 0;
}
Популярно: Информатика
-
Фидан7771412.06.2021 19:12
-
guna312.03.2021 15:52
-
Vladarmani30.11.2020 14:01
-
Shakhinya0127.11.2022 19:35
-
SophiakoSheleva566624.09.2022 09:31
-
qwvt720.05.2023 08:50
-
Данил932306.03.2021 19:15
-
LidaDay02.01.2023 20:52
-
Черный281509.04.2020 19:22
-
ivanmyas07.12.2022 10:00