I am writing a program that converts arabic numbers to mayan numbers and vice versa. I got the converting arabic numbers to mayan down perfect but I am really struggling to write a function converting mayan numbers to arabic. incase you don't know arabic numbers are regular 1 2 3 numbers and mayan numbers are represented by 0 . and -

the conversion table looks like this

0 0 | 5 - | 10 -- | 15 ---

1 . | 6 .- | 11 .-- | 16 .---

2 .. | 7 ..- | 12 ..-- | 17 ..---

3 … | 8 …- | 13 …-- | 18 …---

4 …. | 9 ….- | 14 ….-- | 19 ….---

mayan numbers are base 20 and written backward so to Covert Mayan to Arabic you go like this:

Mayan = ..-- .. ….--- 0 (12 2 19 0)

Arabic = 0 * 20^0 + 19 * 20^1 + 2 * 20^2 + 12* 20^3 = 97180

I read in the Mayan number as a char array and now have to create a function that converts the mayan number and returns an arabic number. This is what I have written so far but I am afraid I went in the completely wrong direction and there is a much easier way to solve this than I am attempting to. Any help would be great, Thanks!

Code:

int counter=0;
int final=0;
int temp[20];
int temp2[50];
for(int q=0; q < 50; q++)
temp2[q] = 0;
for(int j=0; j < 20; j++)
temp[j] = 0;
for(int t=0; t < 25; t++)
{
for(int p=0; p < 25; p++)
{
if(MayanNumber[t] != '#') //MayanNumber array is declared as all #'s after the number
{
if(MayanNumber[t] != ' ')
{
switch(MayanNumber[t])
{
case '0':
temp[counter] = 0;
counter++;
break;
case '.':
temp[counter] = 1;
counter++;
break;
case '-':
temp[counter] = 5;
counter++;
break;
}
}
else
{
for(int k=0; k < counter; k++)
temp2[p] = temp2[p] + temp[k];
}
}
}
}
//I havent written the part that tallys up every number yet but it will be assigned to 'final'
return final;