Есть ответ 👍

Написать программу, которая на вход получает 2 множества, а при выходе даёт 4 множества. можно на любом языке программирования. а ещё если не сложно , на псевдокоде.

216
434
Посмотреть ответы 2

Ответы на вопрос:

zulya24
4,5(80 оценок)

кроме 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;

}


Фрифаер топ

Объяснение:

Фф топ ¯\_(ツ)_/¯¯\_(ツ)_/¯¯\_(ツ)_/¯¯\_(ツ)_/¯

Популярно: Информатика