Skip to content

Instantly share code, notes, and snippets.

View fabianosalles's full-sized avatar

Fabiano Salles fabianosalles

View GitHub Profile
#include "list.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdbool.h>
typedef void(*CallbackFree)(void *);
typedef int(*CallbackCompare)(void *a, void *b);
typedef struct _node {
void free_node_data(CallbackFree free_callback, void *data) {
if (free_callback != NULL)
free_callback(data);
else
free(data);
}
void list_remove(List *list, int index) {
assert(list != NULL);
void list_add(List *list, void *data) {
assert(list != NULL);
assert(data != NULL);
Node *newNode = calloc(sizeof(Node), 1);
newNode->data = malloc(list->data_size);
memcpy(newNode->data, data, list->data_size);
if (list->head == NULL) {
list->head = newNode;
list->tail = newNode;
typedef void(*CallbackFree)(void *);
typedef struct _node {
void *data;
struct _node *next;
} Node;
typedef struct {
int count;
int data_size;
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <string.h>
#define MAX_BUFFER 64
char *remove_alpha(char *buffer) {
int i, j = 0;
char *result = calloc(sizeof(char), MAX_BUFFER);
#include <stdio.h>
#include <Windows.h>
void displayError();
int main(void) {
WIN32_FIND_DATA data;
HANDLE hSearch = FindFirstFileA("C:\\temp\\*.txt", &data);
if (hSearch != INVALID_HANDLE_VALUE) {
do {
{em pascal}
function CollideRect(ball: PRect; const x0, y0, x1, y1: byte): boolean;
begin
result:=
(
((ball^.x >= x0) and (ball^.x <= x1)) or
((ball^.x + BALL_W >= x0) and (ball^.x+BALL_W <= x1))
and
((ball.y >= y0) and (ball.y <= y1)) or
((ball.y+BALL_H >= y0) and (ball.y+BALL_H <= y1))
#include <stdio.h>
#include <stdlib.h>
typedef struct item {
char content;
struct item* next;
} item;
/*
* retorna sempre o último item da lista
/*
Solução para o problema: https://www.urionlinejudge.com.br/judge/en/problems/view/1103
O programa resolve o problema para todos os casos de teste quando compilado sem o uso do
operador ternário do C. Quando a mesma expressão é montada utilizando-o, ele gera alguns
resultados errados.
Estou utilzando o compilador C da Microsoft para x86 sem otimizações através do comando:
cl 1103.c