Skip to content

Instantly share code, notes, and snippets.

View lucarinelli's full-sized avatar

Luca Rinelli lucarinelli

View GitHub Profile
@lucarinelli
lucarinelli / laib8ex1.c
Last active November 26, 2017 11:19
LAIB 8 Exercise 1: Magic square
#include <stdio.h>
#include <stdlib.h>
int rs[]={1,0,0,0},cs[]={0,1,0,0},rc[]={0,1,1,1},cc[]={1,0,1,-1};
int magic_r(int **magic_square,int n,int row,int col,int target_sum,int *marked,int n_elements){
int i,j,k,sum,under=1,wrong;
for(i=1;i<=n_elements&&under;i++){
if(!marked[i-1]){
magic_square[row][col]=i;
@lucarinelli
lucarinelli / laib8ex2.c
Last active November 26, 2017 18:53
LAIB 8 Exercise 2: Gray Code
#include <stdio.h>
#include <stdlib.h>
char s[]={'0','1'};
int power(int b, int e){
return e!=0?b*power(b,e-1):1;
}
void gray_r(char **matrix,int n,int shift,int symbol){
@lucarinelli
lucarinelli / laib9ex1.c
Created December 4, 2017 00:32
LAIB 9 Exercise 1: Maze
#include <stdio.h>
#include <stdlib.h>
#define HUMAN '@' //indicates the initial position of a human being
#define CORRIDOR ' ' //represents corridors (empty cells)
#define EXIT '#' //represents exit points
#define TRAMPLED 1 //already been here
#define NOT_TRAMPLED 0
//Check up,left,down,right
@lucarinelli
lucarinelli / 20160222.c
Created January 4, 2018 16:45
My first solution of the 18 points exam 20160222
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//DA RIFARE PALESEMENTE CON L'ADJACENCY MATRIX
enum color{RED,BLACK};
enum yesno{YES,NO};
typedef struct edge_t edge_t;
@lucarinelli
lucarinelli / 20150202.c
Last active January 5, 2018 17:19
My first solution of the 18 points exam 20150202
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
typedef struct props_list_item_t props_list_item_t;
#define ABS(a) (a)<0?(-(a)):(a)
struct props_list_item_t{
int val;
@lucarinelli
lucarinelli / 20150223.c
Created January 24, 2018 09:34
20150223 my solution
#include <stdio.h>
#include <stdlib.h>
#define dieIf(a,b) if(a){printf(b);exit(EXIT_FAILURE);}
typedef struct v_list_t v_list_t;
typedef struct v_t v_t;
typedef struct e_t e_t;
typedef struct path_t path_t;
typedef struct v_table_t v_table_t;
@lucarinelli
lucarinelli / 20160909.c
Created January 24, 2018 16:20
20160909 my solution
#include <stdio.h>
#include <sdtlib.h>
#define lastWords(a,b) if(a){printf(b);exit(EXIT_FAILURE);}
typedef struct v_item_t v_item_t;
typedef struct v_set_t v_set_t;
typedef struct v_t v_t;
typedef struct simbolTable_t st_t;
@lucarinelli
lucarinelli / 20180129.c
Last active January 30, 2018 11:02
20180129
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "myUtils.h"
#include "myHT.h"
typedef struct item_t i_t;
typedef struct set_t s_t;
int comb_r(s_t *workers, s_t *firms, int current, int N);
@lucarinelli
lucarinelli / 20180129.c
Last active January 29, 2018 22:54
20180129.c 2
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "myUtils.h"
#include "myHT.h"
typedef struct item_t i_t;
typedef struct set_t s_t;
int comb_r(s_t *workers, s_t *firms, int current, int N);
@lucarinelli
lucarinelli / main.c
Last active January 30, 2018 17:11
20180129
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "myUtils.h"
#include "myHT.h"
typedef struct item_t i_t;
typedef struct set_t s_t;
int comb_r(s_t *workers, s_t *firms, int current, int N);