A decomposition algorithm of skew-symmetric and skew-symmetrizable exchange matrices