the basketball places are usually outdoors, and they are located in some parks in the city. just ask to anyone in your neighbourhood... ¿hay algún polideportivo por aquí o alguna chancha de baloncesto?
they will know.
the swimming thing, maybe in the university there's a swimming pool, ask there. pool is piscina, for sure there will be some pools in Madrid indoors and open to public. you could ask in the tourist office.
[This message has been edited by Antonio (edited 02-05-2001).]