This repository was archived by the owner on Jan 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.cpp
More file actions
49 lines (36 loc) · 1.27 KB
/
program.cpp
File metadata and controls
49 lines (36 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <algorithm>
#include <set>
#include <iterator>
struct Person{
std::string imie;
std::set<std::string>przyjaciele;
};
void wprowadzImiona(Person & p);
int main(){
using namespace std;
Person bolek, lolek;
bolek.imie = "Bolek"; lolek.imie = "Lolek";
wprowadzImiona(bolek); wprowadzImiona(lolek);
cout << "***Przyjaciele Bolka***\n";
for(const auto & p : bolek.przyjaciele){ cout << p << endl; }
cout << "***Przyjaciele Lolka***\n";
for(const auto & p : lolek.przyjaciele){ cout << p << endl; }
set<string>goscie;
set_union(bolek.przyjaciele.begin(),bolek.przyjaciele.end(),
lolek.przyjaciele.begin(),lolek.przyjaciele.end(),
insert_iterator<set<string>>(goscie,goscie.begin()));
cout << "***Urodzinowi Goście***\n";
ostream_iterator<string,char> out(cout,"\n");
copy(goscie.begin(),goscie.end(),out);
cout << "--------------\n";
}
void wprowadzImiona(Person & p){
using std::cout; using std::endl; using std::cin;
cout << "Wpisuj imiona przyjaciół użytkownika " << p.imie << ". ";
cout << "Pusty wiersz kończy wprowadzanie:\n";
cout << "Podaj imię: "; std::string imie; getline(cin,imie);
while(imie!=""){
p.przyjaciele.insert(imie); cout << "Następne imię: "; getline(cin,imie);
}
}