Electronic theory for segregation at the surface of transition-metal alloys