#include<stdio.h>
#include<conio.h>
#include<math.h>
/*
Ý TƯỞNG ???
VD:
1 => Mot
12 => "Muoi" Hai
123 => Mot "Tram" Hai "Muoi" Ba
1234 => Mot "Ngan" Hai "Tram" Ba "Muoi" Bon
12345 => "Muoi" Hai "Ngan" Ba "Tram" Bon "Muoi" Lam
123456 => Mot "Tram" Hai "Muoi" Ba "Ngan" Bon "Tram" Nam "Muoi" Sau
1234567 => Mot "Trieu" Hai "Tram" Ba "Muoi" Bon "Ngan" Nam "Tram" Sau "Muoi" Bay
Bước 1: Đảo số ban đầu lại để lúc bóc từng chữ số ra nó đi theo thứ tự
1234 => 4321
Bước 2: Sau khi bóc ra chữ số và đọc nó ra thì tiếp tục kiểm tra nếu đằng sau
nó còn bao nhiêu chữ số thì sẽ đọc phụ âm đi kèm theo nó ứng với số chữ số còn lại
*/
/*
n = 123
songhichdao = 0
songhichdao = songhichdao * 10 + n % 10
lần 1: songhichdao = 3
n = 12
lần 2: songhichdao = 32
n = 1
lần 3: songhichdao = 321
n = 0 => end
*/
void DaoNguoc(int &n)
{
int songhichdao = 0;
while (n != 0)
{
songhichdao = songhichdao * 10 + n % 10;
n /= 10; // Bỏ chữ số vừa lấy ra
}
n = songhichdao;
}
void DocChuSo(int chuso)
{
if (chuso == 1)
{
printf("Mot ");
}
else if (chuso == 2)
{
printf("Hai ");
}
else if (chuso == 3)
{
printf("Ba ");
}
else if (chuso == 4)
{
printf("Bon ");
}
else if (chuso == 5)
{
printf("Nam ");
}
else if (chuso == 6)
{
printf("Sau ");
}
else if (chuso == 7)
{
printf("Bay ");
}
else if (chuso == 8)
{
printf("Tam ");
}
else if (chuso == 9)
{
printf("Chin ");
}
}
void DocPhuAm(int sochuso)
{
if (sochuso == 3)
{
printf("Ngan ");
}
else if (sochuso == 2)
{
printf("Tram ");
}
else if (sochuso == 1)
{
printf("Muoi ");
}
}
void DocSo(int n)
{
int SoChuSo = (int)log10((float)n) + 1;
while (n != 0)
{
int ChuSo = n % 10; // Lấy chữ số
n /= 10; // Loại bỏ chữ số vừa lấy
SoChuSo--;
DocChuSo(ChuSo);
DocPhuAm(SoChuSo);
}
}
int main()
{
int n = 1224;
DaoNguoc(n);
DocSo(n);
_getch();
return 0;
}