Skip to content

Instantly share code, notes, and snippets.

typedef struct tnode{
int flag; //indicate whether the node is a leaf(0: number; 1: variable) or internal node(2: operator)
char *varname; //name of the variable
int val; //value of the expression tree
char *op; //operator branch
struct tnode *left, *right; //left and right node
}tnode;
#include <string.h>
#define TOTAL 50
int yyerror(char const *s);
typedef struct tnode{
int flag; //indicate whether the node is a leaf(0: number; 1: variable) or internal node(2: operator)
// char *varname; //name of the variable
// int val; //value of the expression tree
struct variable *var;
struct temp {
char *name; //temporary variable name
int flag; //indicate whether the variable is free(0: free; 1: used)
} temps[TOTAL];
void inittemps();
struct temp *gettemp();
void freetemp(struct temp *t);
tnode tnodes[TOTAL];
struct expr{
int flag;
char *expr;
}exprstack[TOTAL];
struct quad{
int flag;
struct variable *operation;
struct variable *arg1;
struct variable *arg2;
struct variable *result;
struct quad *next;
}quads[TOTAL];
// remove the duplicate assignment
struct variable {
int used; // 0: not used; 1: used
int flag; // 0: integer; 1: variable; 2: temporary; 3: operator
char *name;
int value;
};
struct variable variables[TOTAL];
struct variable temps[TOTAL];
struct RWTable{
int flag; // 0: init; 1: read first
struct variable *var;
int read[RWTOTAL];
int write[RWTOTAL];
struct RWTable *next;
};
struct dataDependTable{
int used;
struct copyStatement{
int used;
struct variable *result;
struct variable *arg;
}copyTable[COPYTABLESTOTAL];
// look up the copyTables
struct copyStatement *lookupCopyTables();
// build copyTables
  1. login server
  • ssh username@@montana.dataapplab.com -p 49233
  • mkdir .ssh
  1. on your computer, open terminal
  • check the ~/.ssh exists, if not mkdir ~/.ssh
  • generate ssh keys: ssh-keygen -t rsa -f ~/.ssh/id_rsa.dal
  • edit config vim .ssh/.config, type:
    Host dal

User bhdshaox

import sys

def perimeter(rectangles):
    perimeter = 0
    edges = {}
    
    for rect in rectangles:
        x1, y1, x2, y2 = map(int, rect.split())
        perimeter += 2 * (x2 - x1 + y2 - y1)