Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.c
- // foo
- //
- // Created by Lorenzo Piana on 24/09/2016.
- // Copyright © 2016 Lorenzo Piana. All rights reserved.
- //
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- typedef struct { double x ; double y;} point;
- void pointShow(point *p){
- printf("%f %f\n", p->x, p->y);
- };
- void pointDist(point *p, point *pp){
- double Xab = (p->x)-(pp->x);
- double Yab = (p->y)-(pp->y);
- double d = sqrt(pow(Xab, 2) + (pow(Yab, 2)));
- printf("%f\n", d);
- };
- int pointEq(point *p, point *pp){
- if((p->x == pp->x) && (p->y == pp->y) ){
- return 1;}
- else{
- return 0;
- }
- };
- typedef struct{
- point p1;
- point p2;
- }rect;
- int main(int argc, const char * argv[]) {
- point p1;
- point p2;
- point *p;
- point *pp;
- p = &p1;
- pp = &p2;
- p1.x = 0.3;
- p1.y = 0.2;
- p2.x = 0.4;
- p2.y = 0.5;
- pointShow(p);
- pointDist(p, pp);
- pointEq(p, pp);
- rect r1;
- printf("%f\n", r1.p2.x);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement