Quick actions

cmd+k|ctrl+k

Navigation

Languages

Distancia euclidiana

Snippet info

Language

C

Visibility

public

Author

rodrigogons

Created

2017-02-15T22:29:00Z

Updated

2017-02-15T22:29:00Z

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

struct pto
{
    float x;
    float y;
};

int main()
{
    typedef struct pto ponto;
    
    int i;
    ponto a, b;
    
    a.x = 1.0;
    a.y = 1.0;
    
    b.x = 3.0;
    b.y = 3.0;
    float soma = 0.0;

    for(int i = 0; i < 2; i++)
    {
        soma += (pow((a.x - b.x),2) + pow((a.y - b.y),2));
    }
    
    sqrt(soma);
    
    printf("%.2f",soma);
    
    return 0;
}
INFO