need idea on how to Convert Arabic to Mayan number

Does anyone have an idea on how to Convert Arabic to Mayan number:
Arabic = 1222
Mayan = … . ..
1222/20 = 61 remainder 2 ..
61/20 = 3 remainder 1 .
3/20 = 0 remainder 3 …

So far, I can only picture how to get a remainder.
remainder = num % 20;

But shall I do next?

Thank you.
Ok, having been to this site: http://www.michielb.nl/maya/math.html

Since it is base 20, divide the number by 20. That will give you the multiples of 20 that number represents. Then subtract 20 * multiple to get the remainder. So 274 would be:

274 / 20 = 13

274 - (20 * 13) = 274 - 260 = 14

so 13 and 14.

Using modulus, you only get the remainder, but not the multiples of 20.

I suppose you could do:

int remainder = number % 20;
int quotient = number / 20;
Last edited on
I got a problem storing a remainder into an array, please help. Thank you!

#include <iostream>
#include <string>
#include <cmath>

using namespace std;
int main ()
{

//// /*Convert Arabic to Mayan:
//// Arabic = 1222
//// Mayan = … . ..
//// 1222/20 = 61 reminder 2 ..
//// 61/20 = 3 reminder 1 .
//// 3/20 = 0 reminder 3 …*/
int remainder, num;
int temp[50];
cout << "Enter Arabic num" << endl;
cin >> num;

do

{
remainder = num % 20;
int i =0;
{
cin >> temp [i] = remainder; // PROBLEM HERE??
i++;
}
num = num / 20;

} while (num !=0);

return 0;

}
Why do you need a cin? You already input num. Now you can calculate stuff based on that or get more info from the user, but you can't do both at the same time. Get rid of the cin, that will give you an array of remainders.

Note that your array will all be the same number:
1
2
3
4
67%20 = 7;  67/20 = 3;
47%20 = 7;  47/20 = 2;
27%20 = 7;  27/20 = 1;
07%20 = 7;  07/20 = 0;
Last edited on
@EaAA: LOL! You can't use the = operator in cin! Wait, were you trying to.. OMG. cin means console input!!!
here:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <string>
#include <cmath>

using namespace std;
int main ()
{

//// /*Convert Arabic to Mayan:
//// Arabic = 1222
//// Mayan = … . ..
//// 1222/20 = 61 reminder 2 ..
//// 61/20 = 3 reminder 1 .
//// 3/20 = 0 reminder 3 …*/
int remainder, num;
int temp[50];
cout << "Enter Arabic num" << endl;
cin >> num;
int i=0
do

{
remainder = num % 20;
 temp [i]=remainder;
i++;
num = num / 20;

} while (num !=0);

return 0;

}

this should do it. I have NO idea what you did there with those brackets, and why you declared i inside the loop, but this SHOULD do it. try it out yourselves too!
thank you guys, it works:)
I am still trying to figure out how to output the Mayan number
so far can print out array with Arabic number in a reverse order, but how do I go about the Mayan = … . .. ???

Arabic = 1222
Mayan = … . ..
1222/20 = 61 remainder 2 ..
61/20 = 3 remainder 1 .
3/20 = 0 remainder 3 …

#include <iostream>
#include <string>
#include <cmath>

using namespace std;
int main ()
{
int remainder, num;
int temp[50];
int i =0;
cout << "Enter Arabic num" << endl;
cin >> num;

do

{
remainder = num % 20;
temp [i] = remainder;
i++;
num = num / 20;

} while (num !=0);


for (int n=i-1; n>=0; n--)
{
cout << temp [n];

}

return 0;

}
Last edited on
Topic archived. No new replies allowed.