Skip to content

Instantly share code, notes, and snippets.

#include<bits/stdc++.h>
#define DIST(x1,x2, y1, y2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)))
#define DIST3D(x1,x2, y1, y2, z1, z2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)) + ((z1-z2)*(z1-z2)))
#define CLR(a) a.clear()
#define VCLR(a, n) for(int i=0; i<=n+3; i++) a[i].clear()
#define SIZE(a) a.size()
#define ERASE(a, b) memset(a, b, sizeof a)
#define PB(a, b) a.push_back(b)
#define PB2(a,i,b) a[i].push_back(b)
#define LL long long
@ssavi
ssavi / Basic Gauss Elimination.cpp
Last active October 30, 2016 15:57
Numerical Method ( Lab Code.c)
#include<bits/stdc++.h>
#define eps 0.000001
using namespace std;
double a[50][50], b[50], x[50];
void GAUSS(int n, double a[50][50], double b[50], double x[50], int *status)
{
double pivot, factor, sum;
@ssavi
ssavi / FCFS.c
Created October 30, 2016 12:50
Operating System ( Lab Code.c )
#include<stdio.h>
#include<process.h>
int main()
{
char p[10][5];
int tot=0,wt[10], pt[10], i,n;
double avg=0;
printf("enter no of processes: ");
scanf("%d",&n);
@ssavi
ssavi / Prog - 10.m
Last active November 2, 2016 15:15
( This Files ran Successfully on Online Octave Platform )
%To illustrate the Rectangular Waveguide TM mode using MATLAB
clc;
close all;
clear all;
f=8e9;
w=2*pi*f;
t=1/f;
L=3e11/f;
B=2*pi/L;
@ssavi
ssavi / euler_phi.cpp
Created January 22, 2017 05:32 — forked from cslarsen/euler_phi.cpp
Euler's totient function phi --- a fast implementation in C++
/*
* Euler's totient function phi(n).
* http://en.wikipedia.org/wiki/Euler%27s_totient_function
*
* This is an *EXTREMELY* fast function and uses
* several tricks to recurse.
*
* It assumes you have a list of primes and a fast
* isprime() function. Typically, you use a bitset
* to implement the sieve of Eratosthenes and use