Skip to content

Instantly share code, notes, and snippets.

@douglas-vaz
douglas-vaz / palindrome.c
Created June 12, 2012 17:59
Palindrome using stack and queue
//Palindrome
#include "stdio.h"
#include "stdlib.h"
struct Node{
char info;
struct Node *next;
};
@douglas-vaz
douglas-vaz / stc.c
Created June 14, 2012 07:58 — forked from tanayseven/gist:2928879
Stack
#include<stdio.h>
#include<stdlib.h>
struct stack
{
int info;
struct stack *next;
};
typedef struct stack *s;
@douglas-vaz
douglas-vaz / evav_in.c
Created June 14, 2012 19:00
Infix to Postfix and evaluate
#include <stdio.h>
#include <stdlib.h>
struct Node{
int info;
struct Node *next;
};
typedef struct Node *nodeptr;
@douglas-vaz
douglas-vaz / gist:3075892
Created July 9, 2012 11:19
Real Number DFA
import java.io.*;
public class Real
{
public static void main(String[] args)
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String in;
try{
System.out.println("Enter string");
in = br.readLine();
import java.io.*;
public class Identifier
{
public static void main(String [] args)throws IOException
{
String id;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a string: ");
include io.h
cr equ 0dh
lf equ 0ah
data segment
la db cr,lf,'Enter a',0
lb db cr,lf,'Enter b',0
l1 db cr,lf,'Enter x',0
ly db cr,lf,'Enter y',0
@douglas-vaz
douglas-vaz / sum_a.asm
Created July 18, 2012 09:48
MASM Sum Average
include io.h
data segment
lf db 0dh,0
cr db 0ah,0
n_prompt db "Enter n:",0
num_prompt db "Enter number",0
res_sum db "Sum = ",0
res_avg db "Average = ",0
n dw 40 DUP(?)
@douglas-vaz
douglas-vaz / py_dfa_alc2.py
Created July 23, 2012 18:20
Python DFA to validate strings containing "abac"
#!/usr/bin/python2
print "Enter a string"
str = raw_input()
state = 0
dfa = [{'a':1,'b':0,'c':0},{'b':2,'a':0,'c':0},{'a':3,'b':1,'c':0},{'c':4,'a':2,'b':1},{'a':4,'b':4,'c':4}]
for i in str:
print i,': ',state,' -> ',
state = dfa[state][i]
@douglas-vaz
douglas-vaz / evodd1.asm
Created July 25, 2012 10:03
8086 Assembly count even and odd using RCR
include io.h
data SEGMENT
lf db 0dh,0
cr db 0ah,0
n_prompt db 'Enter size of array',0
el_prompt db 'Enter elements',0
odd_prompt db 'Odd = ',0
even_prompt db 'Even = ',0
n dw 40 dup(?)
@douglas-vaz
douglas-vaz / index_cdr.html
Created August 9, 2012 16:39
Cross domain request using callback added to a dynamic script element
<!DOCTYPE html>
<html>
<head>
<!--
Enter your script name in the text box and hit submit. Have a callback in the url and the form data. The callback function should execute.
-->
</head>
<body>
<form>