Skip to content

Instantly share code, notes, and snippets.

@Biazus
Biazus / hash.c
Last active August 29, 2015 14:07
Etapa 5 Compiladores - hash
HASh_NODE *makeTemp(void)
{
static int nextTemp = 0;
static char tempName[256];
sprintf(tempName,"myStrangeeTemp%d", nextTemp++);
return hashInsert(HASH_VARIABLE, tempName);
}
HASh_NODE *makeLabel(void)
@Biazus
Biazus / tacalepau.c
Last active August 29, 2015 14:07
Etapa 5 Compiladores
#include "tacalepau.h"
#include<stdlib.h>
TAC* makeBinOp(int type, TAC* code0, TAC* code1);
TAC* makeIf(TAC* code0, TAC* code1);
TAC* tacCreate(int type, HASH_NODE *res, HASH_NODE *op1, HASH_NODE *op2){
TAC* newtac = 0;
newtac = (TAC*) calloc(1,sizeof(TAC));
@Biazus
Biazus / main.cpp
Last active February 14, 2023 17:11
Desafios: Let Me Count The Ways
#include<cstdio>
#include<iostream>
//Fácil - Let Me Count The Ways
using namespace std;
int main() {
long ways[30001] = {0}; //se nao colocar double da valor negativo
@Biazus
Biazus / main.cpp
Created September 14, 2014 21:29
Desafios: Bicoloring
#include <iostream>
using namespace std;
int matrix[199][199]; //maximo eh 200
int gr[199];
int x[199];
bool isBicolorable;
void f(int n){
@Biazus
Biazus / main.cpp
Last active February 14, 2023 17:11
Desafios: The Monocycle
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
struct pos{
int d; //0:North, 1:East, 2:South, 3:West
int z; //0:green, 1:white, 2:blue, 3:red, 4:black
int i;
@Biazus
Biazus / main.cpp
Created September 12, 2014 06:43
Desafios: Beverage
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;
map<string, int> Map;
string Name[105];
vector<int> toNxt[105];
int beConnected[105];
@Biazus
Biazus / parser.y
Created September 4, 2014 03:31
comp
%{
#include <stdio.h>
#include <stdlib.h>
#include "hash.h"
extern int getLineNumber(void);
extern int isRunning(void);
%}
@Biazus
Biazus / main.cpp
Created August 22, 2014 14:27
Desafios: Big Numbers of Teams Will Solve This
//Big Numbers of Teams Will Solve This
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
@Biazus
Biazus / main.cpp
Created August 22, 2014 14:24
Desafios: Division of NLogonia
//Division of NLogonia
#include <iostream>
using namespace std;
int main() {
int n, px, py, x, y;
cin >> n;
while (1) {
cin >> px >> py;
while (1) {
cin >> x >> y;
@Biazus
Biazus / main.cpp
Created August 22, 2014 14:23
Desafios: 3n+1
// 3n+1
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
int i, j, k, l, n, partial=0, maximum=0, resto, troca=1;