/*
Returns difference in time between a given start hour,
start min and end hour and end min
*/
int difftime(int sh, int sm, int eh, int em)
{
int s, e ;
s = 60*(sh-0) + sm ;
e = 60*(eh-0) + em ;
e -=s ;
if (e < 0)
e += 60 * 24 ;
return e ;
}
Pages
Labels
01 Knapsack
(1)
Ad Hoc
(1)
Backtracking
(1)
Binary Search Tree
(1)
bits
(1)
Brute Force
(1)
codelib
(2)
Data Structures
(1)
Dijkstra
(1)
DP
(2)
Graphs
(1)
Heaps
(1)
Joseph
(1)
Maximum 1-D Sum
(1)
Maximum Contiguous Sum
(1)
Primes
(1)
Priority Queues
(1)
Recursion
(1)
Sieve of Atkins
(1)
UVaOJ Vol-102
(1)
UVaOJ Vol-109
(1)
UVaOJ Vol-5
(1)
Showing posts with label codelib. Show all posts
Showing posts with label codelib. Show all posts
Saturday, January 22, 2011
Difference in time
Thursday, January 6, 2011
Useful Bit-manipulation Functions
/* Function to print binary representation of a number */
void printBinary(int n)
{
int i ;
for (i=31; i>=0; i--)
printf("%d", ((1<<i & n))?1:0) ;
printf("\n") ;
}
/* Function to get 2's complement of a number */
int get2scomplement(int n)
{
int i, k=0 ;
for (i=0; i<32; i++)
k |= ~(1<<i | n) ;
k+=1 ;
return k ;
}
Subscribe to:
Posts (Atom)