Take the two bars, and put them together like a T, so that one bisects the other.
|bar A ->||
|bar B ---------->||
If they stick together, then bar B is the magnet. If they don't, bar A is the magnet. (reasoning follows)
Bar magnets are "dead" in their centers (i.e., there is no magnetic force, since the two poles cancel out). So, if bar A is the magnet, then bar B won't stick to its center.