As a general rule, if you take the sum of the valence electrons on the central atom and the total number of e- the other atoms need to make a full octet, then divide by two, then you get the number of e- pairs around the central atom. Here's the formula in a clearer form:
(# valence e- on central atom) + (total # of e- needed by other atoms for a full octet)
2
for instance, in ammonia, NH3, the N has 5 valence electrons, and each of the hydrogens needs one more e- for a full octet. Therefore, (5+3)/2= 4, there are four pairs of electrons around the N. since there are only three things bonded, that means that one of those pairs is a non-bonding pair. Use this formula for the two molecules you suggested, and you will find your answer. Remember, a non-bonding pair of electrons effects the shape just as much as a bonding pair would.