This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct item { | |
char content; | |
struct item* next; | |
} item; | |
/* | |
* retorna sempre o último item da lista |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef void(*CallbackFree)(void *); | |
typedef struct _node { | |
void *data; | |
struct _node *next; | |
} Node; | |
typedef struct { | |
int count; | |
int data_size; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* declaração de um nó de uma lista de inteiros. */ | |
typedef struct _node { | |
int data; | |
struct _node *next; | |
} Node; | |
/* declaração de um nó para uma lista de string */ | |
typedef struct _node { | |
char *data; | |
struct _node *next; |
OlderNewer