In effetti faresti prima ad usare l'operatore modulo (%)...
Amaro C++, il gusto pieno dell'undefined behavior.
Regole del Forum