Le 28 juin 2021 à 13:09:30 :
En C/C++
if ( a ^ b ^ c ^ d ) { ... }
ou
if ( a + b + c + d == 3 ) { ... }
En C#
if ( (int)a ^ (int)b ^ (int)c ^ (int)d == 1 ) { ... }
ou
if ( (int)a + (int)b + (int)c + (int)d == 3 ) { ... }
Petite erreur, a ^ b ^ c ^ d retoure 1 quand exactement 3 sont fausses
Mais !a^!b^!c^!d retourne 3 quand exactement 3 sont justes
Message édité le 28 juin 2021 à 14:01:47 par SemenceDeCobra