c++ in va doc so 2 chu so
// Author : Ngo Tien Dat
// Purpose : Print written form of two digit numbers
// Date : 09 March 2009
#include <iostream>
using namespace std;
int main()
{
int number;
int ten; // Chu so hang chuc
int unit; // Chu so hang don vi
do
{
cout << "number = ";
cin >> number;
if (number < 10 || number > 99) {
break;
}
ten = number / 10;
unit = number % 10;
switch (ten)
{
case 1:
cout << "Muoi";
break;
case 2:
cout << "Hai muoi";
break;
case 3:
cout << "Ba muoi";
break;
case 4:
cout << "Bon muoi";
break;
case 5:
cout << "Nam muoi";
break;
case 6:
cout << "Sau muoi";
break;
case 7:
cout << "Bay muoi";
break;
case 8:
cout << "Tam muoi";
break;
case 9:
cout << "Chin muoi";
break;
}
switch (unit)
{
case 1:
cout << " mot";
break;
case 2:
cout << " hai";
break;
case 3:
cout << " ba";
break;
case 4:
cout << " bon";
break;
case 5:
cout << " lam";
break;
case 6:
cout << " sau";
break;
case 7:
cout << " bay";
break;
case 8:
cout << " tam";
break;
case 9:
cout << " chin";
break;
}
cout << "
";
}
while (true);
return 0;
}
Bạn đang đọc truyện trên: AzTruyen.Top