Skip to content

Instantly share code, notes, and snippets.

@arthurxavierx
arthurxavierx / dfs.c
Created May 22, 2013 17:59
Algoritmo de Busca em Profundidade em um grafo. Encontra um vértice em um labirinto e o caminho até este.
/** dfs.c
* @author Arthur Xavier <arthur.xavierx@gmail.com>
* @usage
* $ gcc dfs.c
* $ ./a.out < maze1.txt
*/
#include <stdio.h>
#include <stdlib.h>
/**
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeOperators #-}
-- | This type class describes operations that can be performed over Servant
-- API trees. The instances essentially distribute the actions over the ':<|>'
-- constructor, and apply them to the leaves of the API trees: functions or
-- values in an applicative functor.
@arthurxavierx
arthurxavierx / registros.c
Created June 6, 2013 01:50
Lista de exercícios 8 - Registros
typedef struct PONTO {
float x, y;
} PONTO;
void atribuiValorPonto(PONTO* p, float a, float b) {
p->x = a;
p->y = b;
}
float dist(PONTO* p1, PONTO* p2) {
return sqrt(pow(p1.x - p2.x, 2) - pow(p1.y - p2.y, 2));
@arthurxavierx
arthurxavierx / matriz.c
Created May 23, 2013 01:47
Lista de exercícios 7 - Matriz
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define SIZE 3
float media_matriz(int n, float a[][SIZE]) {
float m = 0.0f;
size_t i;
for(i = 0; i < n*SIZE; i++)
@arthurxavierx
arthurxavierx / sudoku.c
Last active December 17, 2015 15:19
Sudoku verifier
/**
* sudoku.c
* @author Arthur Xavier <arthur.xavierx@gmail.com>
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
int main() {
size_t i, j;