Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- class punkty{
- float x, y;
- public:
- punkty( float x1, float y1){
- x=x1;
- y=y1;
- }
- void wektor(){
- cout << "Wspolrzedne wektora to: " << "(" << x << "," << y << ")" << endl;
- }
- float odleglosc(){
- float odl;
- odl = sqrt(x*x + y*y );
- return odl;
- }
- void osX(){
- if(y == 0) cout << "Punkt nalezy do osi X" << endl;
- else cout << "Punkt nie nalezy do do osi X" << endl;
- }
- void osY(){
- if (x == 0) cout << "Punkt nalezy do osi Y" << endl;
- else cout << "Punkt nie nalezy do osi Y" << endl;
- }
- int cwiartka(){
- if (x > 0 and y > 0 ) return 1;
- if (x < 0 and y > 0) return 2;
- if (x < 0 and y < 0) return 3;
- if (x > 0 and y < 0) return 4;
- }
- };
- int main()
- {
- int p1, p2;
- cout << "Pierwsza wspolrzedna " << endl;
- cin >> p1;
- cout << "Druga wspolrzedna " << endl;
- cin >> p2;
- punkty A(p1, p2);
- A.wektor();
- cout << "Odleglosc punktu od (0,0) wynosi: " << A.odleglosc() << endl;
- A.osX();
- A.osY();
- cout << "Punkt znajduje sie w cwiartce :" << A.cwiartka() << endl;
- return 0;
- }
- 2. ale nie do konca dziala chyba
- #include <iostream>
- #include <math.h>
- using namespace std;
- class punkty{
- float x, y;
- public:
- punkty( float x1, float y1){
- x=x1;
- y=y1;
- }
- void wektor(){
- cout << "Wspolrzedne wektora to: " << "(" << x << "," << y << ")" << endl;
- }
- float odleglosc(){
- float odl;
- odl = sqrt(x*x + y*y );
- return odl;
- }
- void osX(){
- if(y == 0) cout << "Punkt nalezy do osi X" << endl;
- else cout << "Punkt nie nalezy do do osi X" << endl;
- }
- void osY(){
- if (x == 0) cout << "Punkt nalezy do osi Y" << endl;
- else cout << "Punkt nie nalezy do osi Y" << endl;
- }
- int cwiartka(){
- if (x > 0 and y > 0 ) return 1;
- if (x < 0 and y > 0) return 2;
- if (x < 0 and y < 0) return 3;
- if (x > 0 and y < 0) return 4;
- }
- float getX(){ //AKCESORY
- return x;
- }
- float getY(){
- return y;
- }
- float odleglosc_podanych_punktow(float x2, float y2);
- };
- float punkty::odleglosc_podanych_punktow(float x2, float y2){
- float odl_pod_pun;
- odl_pod_pun = sqrt(pow(x2-x, 2)+ pow(y2-y, 2));
- return odl_pod_pun;
- }
- int main()
- {
- punkty A(3, 4);
- punkty B(12, 13);
- A.wektor();
- cout << "Odleglosc punktu od (0,0) wynosi: " << A.odleglosc() << endl;
- A.osX();
- A.osY();
- cout << "Punkt znajduje sie w cwiartce :" << A.cwiartka() << endl;
- cout << " Odleglosc miedzy A i B wynosi: " << A.odleglosc_podanych_punktow(B.getX(), B.getY()) << endl;
- return 0;
- }
- 3.
- #include <iostream>
- #include <math.h>
- using namespace std;
- class kolo{
- float promien_kola;
- int kolor_wypelnienia;
- kolo(){
- float promien, kolor;
- promien_kola = promien;
- kolor_wypelnienia = kolor;
- }
- }
- int main()
- {
- cout << "Hello World!" << endl;
- return 0;
- }
- /*
- * utworzyc trojkat o trzech wspolrzecnych typu punkt, policzyc pole powierzchni ze wzoru Herona
- */
- 4. TROJKAT
- #include <iostream>
- #include <math.h>
- using namespace std;
- class punkty{
- float x, y;
- public:
- punkty( float x1, float y1){
- x=x1;
- y=y1;
- }
- void wektor(){
- cout << "Wspolrzedne wektora to: " << "(" << x << "," << y << ")" << endl;
- }
- float odleglosc(){
- float odl;
- odl = sqrt(x*x + y*y );
- return odl;
- }
- void osX(){
- if(y == 0) cout << "Punkt nalezy do osi X" << endl;
- else cout << "Punkt nie nalezy do do osi X" << endl;
- }
- void osY(){
- if (x == 0) cout << "Punkt nalezy do osi Y" << endl;
- else cout << "Punkt nie nalezy do osi Y" << endl;
- }
- int cwiartka(){
- if (x > 0 and y > 0 ) return 1;
- if (x < 0 and y > 0) return 2;
- if (x < 0 and y < 0) return 3;
- if (x > 0 and y < 0) return 4;
- }
- };
- class trojkat{
- punkty A, B, C;
- }
- int main()
- {
- int p1, p2;
- cout << "Pierwsza wspolrzedna " << endl;
- cin >> p1;
- cout << "Druga wspolrzedna " << endl;
- cin >> p2;
- punkty A(p1, p2);
- A.wektor();
- cout << "Odleglosc punktu od (0,0) wynosi: " << A.odleglosc() << endl;
- A.osX();
- A.osY();
- cout << "Punkt znajduje sie w cwiartce :" << A.cwiartka() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement