1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| int[,] tableau = { { 0, 9, 4, 6, 8, 2, 7, 1, 3, 5 }, { 9, 4, 6, 8, 2, 7, 1, 3, 5, 0 }, { 4, 6, 8, 2, 7, 1, 3, 5, 0, 9 }, {6, 8, 2, 7, 1, 3, 5, 0, 9, 4} {...}};
System.Text.StringBuilder codePostal = new System.Text.StringBuilder();
codePostal.Append("70-004152-?");
int i=0;
int h=0;
while(codePostal[10].ToString()=="?"){
if (h == 10)
{
int cleProduit = 10 - i;
codePostal.Remove(10, 1);
codePostal.Append(cleProduit.ToString());
}
else
{
if (codePostal[h].ToString()!="-")
i = tableau[i, int.Parse(codePostal[h].ToString())];
}
h++;
} |
Partager