Đây là lời giải của mình: #include<iostream>
#include<string.h>
using namespace std;
int doc_so( int n)
{
switch (n)
{
case 0:{cout<<"khong";break;};
case 1:{cout<<"mot";break;};
case 2:{cout<<"hai";break;};
case 3:{cout<<"ba";break;};
case 4:{cout<<"bon";break;};
case 5:{cout<<"nam";break;};
case 6:{cout<<"sau";break;};
case 7:{cout<<"bay";break;};
case 8:{cout<<"tam";break;};
case 9:{cout<<"chin";break;};
default: break;
}
}
int doc_hang(int a)
{
switch(a)
{
case 1000:{cout<<"nghin";break;};
case 100 :{cout<<"tram"; break;};
case 10 :{cout<<"chuc"; break;};
case 1 :{cout<<"don vi";break;};
default:break;
}
}
int main()
{
int n;
cout<<"so can doc la: ";
cin>>n;
int m=n;
int a=1;
while(m>=10)
{
m=int(m/10);
a=a*10;
}
while (a>=1)
{
m=n;
m=m/a;
doc_so(m);cout<<" ";
doc_hang(a);cout<<" ";
n=n%a;
a=a/10;
}
cout<<endl;
system("pause");
}