http://www.cplusplus.com/ref/cstdio/scanf.html

scanf("%u", &a); <-- mancava l'operatore "indirizzo di"...