Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1.
- #include <iostream>
- using namespace std;
- class pies{
- public:
- string gatunek(){
- return "Pies";
- }
- };
- class kot{
- public:
- string gatunek(){
- return "Kot";
- }
- };
- template <typename B, int pojemnosc>
- class Buda{
- B* miejsca_w_budzie[pojemnosc];
- B *buda;
- public:
- void umiesc(B* mieszkaniec, int index){
- miejsca_w_budzie[index]=mieszkaniec;
- }
- B* pokazwierza(int index){
- return miejsca_w_budzie[index];
- }
- };
- int main()
- {
- pies p, p2;
- Buda <pies, 2> bp;
- bp.umiesc(&p,0);
- bp.umiesc(&p2,1);
- for(int i=0; i<2; i++){
- cout << "Pies nr" << i << " to " << bp.pokazwierza(i)->gatunek() << endl;
- }
- kot k, k2;
- Buda <kot, 4> bk;
- bk.umiesc(&k,0);
- bk.umiesc(&k2,1);
- cout << bk.pokazwierza(0)->gatunek() << endl;
- cout << bk.pokazwierza(1)->gatunek() << endl;
- return 0;
- }
- 2.
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- string slowo;
- vector<string> v1;
- while(true){
- cout << "Podaj slowo" << endl;
- cin >> slowo;
- if(slowo == "exit") break;
- else{
- v1.push_back(slowo);
- }
- }
- for(int i =0; i<v1.size(); i++){
- cout << v1[i] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement