Converts a number entered in Arabic to Mayan


I am 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;

}
… . ..


is there a difference between the 4th and the 5th dot ?
Last edited on
yes, here is the chart:


Arabic Mayan A M A M A M
0 0 5 - 10 -- 15 ---
1 . 6 .- 11 .-- 16 .---
2 .. 7 ..- 12 ..-- 17 ..---
3 … 8 …- 13 …-- 18 …---
4 …. 9 ….- 14 ….-- 19 ….---
this is the code i have but theres a single problem. my compiler (maybe yours too) doesnt recognize this sign : … and it writes an à instead. i have no idea how to fix that.
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
33
34
35
36
#include <iostream>
#include <string>
#include <cmath>

using namespace std;
int main ()
{
char space=0x20;
int remainder, num;
int temp[50];
string mayan[]={"0",".","..","…","….","-",".-","..-","…-","….-","--",".--","..--","…--","….--","---",".---","..---","…---","….---"};
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 << mayan[temp [n]] << space;

}
cout <<endl;
system("pause");
return 0;

} 
Last edited on
thank you for sharing it:)

here is what we did

//main.cpp
#include <string>
#include <iostream>
#pragma once
using namespace std;
int main ()

{
int remainder, ArabicNumber;
int temp[50];
int i =0;
cout << "Enter Arabic num" << endl;
cin >> ArabicNumber;
do
{
remainder = ArabicNumber % 20;
temp [i] = remainder;
i++;
ArabicNumber = ArabicNumber / 20;
} while (ArabicNumber !=0);
for (int n=i-1; n>=0; n--)
{
if (temp [n]==0)

cout << "0";
else
{
int numofdashes, numofdots;

numofdashes = temp[n] /5;

numofdots = temp[n] % 5;

for (int g =0; g< numofdashes; g++)

{
cout << "-";
}


for (int p =0; p< numofdots; p++)

{
cout << ".";
}

}

cout << " ";
}
return 0;
}
Topic archived. No new replies allowed.