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;
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;
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.
#include <iostream>
#include <string>
#include <cmath>
usingnamespace 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!
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 = … . .. ???