In the first case, it is clear that the attacker has line of sight. The attacker is totally unobstructed from the target.
In the second case, the attacker does not have line of sight, and cannot attack the target with a sight-dependent attack. The attacker could, however, move to the side, which would allow them to attack the target (whou would have cover).
In the third case, there is line of sight, as the attacker can see the target's square. The target does, however, have cover:
To determine whether your target has cover from your ranged attack, choose a corner of your square. If any line from this corner to any corner of the target’s square passes through a square or border that blocks line of effect or provides cover, or through a square occupied by a creature, the target has cover (+4 to AC). — d20 SRD, "Cover"
I've made a helpful diagram (code) to detail what's happening:
The red lines detail corners which cross through walls. The blue lines detail corners which are questionable at best. The green lines indicate that there is, indeed, line of sight.
The green line from the bottom right of the attacker's square to the top left of the target's square passes through the gap between the spaces; ergo, there is a line of sight. However, every other pair of lines passes through (red) or next to (blue) one wall; ergo, the target has cover.