tmj cadelo belga

Run Settings
LanguageC
Language Version
Run Command
#include <stdio.h> #include "funcao.h" int main(void) { float x, y, soma, sub, tot; Ponto *a = cria(1.0,1.0); Ponto *b = cria(4.0,4.0); acessa(a, &x, &y); printf("Ponto a: %.2f, %.2f \n", x, y); acessa(b, &x, &y); printf("Ponto b: %.2f, %.2f \n", x, y); somaponto(a, b, &soma); printf("a soma eh: %.2f \n", soma); subponto(a, b, &sub); printf("a subtração eh: %.2f \n", sub); manhattan(a, b, &tot); printf("a distancia de manhattan eh: %.2f \n", tot); libera(a); libera(b); return 0; }
#include <stdlib.h> #include<stdio.h> #include<math.h> #include "funcao.h" struct ponto{ float x; float y; float conta; }; Ponto* cria(float x, float y){ Ponto* p = malloc(sizeof(Ponto)); if (p == NULL){ printf("Memoria insuficiente"); exit(1); } p->x = x; p->y = y; return p; } void libera(Ponto* p){ free(p); } void acessa(Ponto* p, float* x, float* y){ *x = p->x; *y = p->y; } void atribui(Ponto* p, float x, float y){ p -> x = x; p -> y = y; } void somaponto(Ponto* v1, Ponto* v2, float* soma){ *soma = v1 ->x + v2->y; } void subponto(Ponto* v1, Ponto* v2, float* sub){ *sub = v1 ->x - v2->y; } void manhattan(Ponto* p1, Ponto* p2, float* tot){ float dx = p2->x - p1 ->x; float dy = p2->y - p1 ->y; *tot = (dx*dx + dy*dy); } //salve do salve
typedef struct ponto Ponto; Ponto* cria(float x, float y); void libera(Ponto* p); void acessa (Ponto* p, float* x, float* y); void atribui (Ponto* p, float x, float y); void somaponto(Ponto* v1, Ponto* v2, float* soma); void subponto(Ponto* v1, Ponto* v2, float* sub); void manhattan(Ponto* p1, Ponto* p2, float* tot);
Editor Settings
Theme
Key bindings
Full width
Lines