Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Zadanie 1
- #include <iostream>
- using namespace std;
- int main()
- {
- float x = 25;
- float *wsk_x;
- wsk_x=&x;
- *wsk_x = x * 10;
- cout << *wsk_x;
- return 0;
- }
- Zadanie 2
- #include <iostream>
- using namespace std;
- struct Posciel{
- float szerokosc;
- float dlugosc;
- string kolor;
- int cena;
- string producent;
- };
- int main()
- {
- Posciel posciel1;
- posciel1.szerokosc=1.8;
- posciel1.dlugosc=2.1;
- posciel1.kolor="Zielony";
- posciel1.cena=99;
- posciel1.producent="PoscielPOL";
- cout << "Szerokosc: " << posciel1.szerokosc << endl;
- cout << "Dlugosc: " << posciel1.dlugosc << endl;
- cout << "Kolor: " << posciel1.kolor << endl;
- cout << "Cena: " << posciel1.cena << endl;
- cout << "Producent: " << posciel1.producent << endl;
- return 0;
- }
- Zadanie 3
- #include <iostream>
- using namespace std;
- class Posciel{
- public:
- float szerokosc;
- float dlugosc;
- string kolor;
- int cena;
- string producent;
- void wyswietl()
- {
- cout << "Szerokosc: " << szerokosc << endl;
- cout << "Dlugosc: " << dlugosc << endl;
- cout << "Kolor: " << kolor << endl;
- cout << "Cena: " << cena << endl;
- cout << "Producent: " << producent << endl;
- }
- float oblicz_powierzchnie(float szerokosc, float dlugosc)
- {
- float p;
- if(szerokosc<=0)
- {
- cout << "Blad podana szerokosc jest mniejsza lub rowna zero";
- return 0;
- }
- else if(dlugosc<=0)
- {
- cout << "Blad podana dlugosc jest mniejsza lub rowna zero";
- return 0;
- }
- else
- {
- p = szerokosc * dlugosc;
- cout << "Powierzchnia wynosi: "<<p;
- return p;
- }
- }
- };
- int main()
- {
- Posciel posciel1;
- posciel1.szerokosc=1.8;
- posciel1.dlugosc=2.1;
- posciel1.kolor="Zielony";
- posciel1.cena=99;
- posciel1.producent="PoscielPOL";
- posciel1.wyswietl();
- posciel1.oblicz_powierzchnie(posciel1.szerokosc,posciel1.dlugosc);
- return 0;
- }
- Zadanie 4
- #include <iostream>
- using namespace std;
- class Posciel{
- public:
- float szerokosc;
- float dlugosc;
- string kolor;
- int cena;
- string producent;
- Posciel(float, float, string, int, string)
- {
- cout << "Szerokosc: " << szerokosc << endl;
- cout << "Dlugosc: " << dlugosc << endl;
- cout << "Kolor: " << kolor << endl;
- cout << "Cena: " << cena << endl;
- cout << "Producent: " << producent << endl;
- }
- }
- Posciel::Posciel (float s, float d, string k, int c, string p)
- {
- szerokosc=s;
- dlugosc=d;
- kolor=k;
- cena=c;
- producent=p;
- }
- int main()
- {
- Posciel okno(1.8, 2.1, "Zielony", 99, "PoscielPOL");
- okno.wyswietl();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement