Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <sstream>
- #include <vector>
- #include <cmath>
- #include <cctype>
- using namespace std;
- struct Point {
- double x;
- double y;
- string s;
- };
- void print(Point p){
- cout << p.s << ": (" << p.x << "," << p.y << ")" << endl;
- }
- Point read(string s){
- Point p;
- cout << s << " taskas, ivesk dvi koordinates: ";
- cin >> p.x >> p.y;
- p.s = s;
- return p;
- }
- double getDistance(Point p, Point q){
- double dx = p.x-q.x;
- double dy = p.y-q.y;
- return sqrt(dx*dx + dy*dy);
- }
- int main(){
- Point p1 = read("Pirmas"); // { 0, 0 };
- Point p2 = { 3, 4 }; // read("Antras");
- Point p3 = { 4, 3, "Trecias" }; // read("Antras");
- cout << "Turime tris taskus: " << endl;
- print(p1);
- print(p2);
- print(p3);
- cout << "Atstumas tarp p1 ir p2 yra " << getDistance(p1, p2) << endl;
- cout << "Atstumas tarp p1 ir p3 yra " << getDistance(p1, p3) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement