Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
5.2 kB
1
Indexable
Never
#include<stdio.h>
#include<math.h>

int main()
{
	int so, sochuso;
	printf("\nnhap vao so = ");
	scanf_s("%d", &so);

	if (so > 1000 || so < 0)
	{
		printf("\nvui long nhap so dung qui dinh");
	}
	else
	{
		int  tram, chuc, donvi;
		tram = so / 100;
		chuc = so % 100 / 10;
		donvi = so % 100 % 10;

		if (tram != 0)
		{
			switch (tram)
			{
			case 1:
			{printf("Mot Tram "); }
			break;
			case 2:
			{printf("Hai Tram "); }
			break;
			case 3:
			{printf("Ba Tram "); }
			break;
			case 4:
			{printf("Bon Tram "); }
			break;
			case 5:
			{printf("Nam Tram "); }
			break;
			case 6: 
			{printf("Sau Tram "); }
			break;
			case 7: 
			{printf("Bay Tram "); }
			break;
			case 8:
			{printf("Tam Tram "); }
			break;
			case 9:
			{printf("Chin Tram "); }
			break;
			}
			if (chuc == 0 && donvi != 0)
			{
				printf("Le ");
				switch (donvi)
				{
				case 1:
				{printf("Mot "); }
				break;
				case 2:
				{printf("Hai "); }
				break;
				case 3: 
				{printf("Ba "); }
				break;
				case 4:
				{printf("Bon "); }
				break;
				case 5: 
				{printf("Nam "); }
				break;
				case 6:
				{printf("Sau "); }
				break;
				case 7:
				{printf("Bay "); }
				break;
				case 8:
				{printf("Tam "); }
				break;
				case 9:
				{printf("Chin "); }
				break;
				}
			}
			else if (chuc != 0 && donvi == 0)
			{
				switch (chuc)
				{
				case 1:
				{printf("Muoi "); } 
				break;
				case 2:
				{printf("Hai Muoi "); }
				break;
				case 3:
				{printf("Ba Muoi "); }
				break;
				case 4:
				{printf("Bon Muoi "); }
				break;
				case 5:
				{printf("Nam Muoi"); }
				break;
				case 6:
				{printf("Sau Muoi "); }
				break;
				case 7:
				{printf("Bay Muoi "); }
				break;
				case 8:
				{printf("Tam Muoi "); }
				break;
				case 9:
				{printf("Chin Muoi "); }
				break;
				}
			}
			else if (chuc != 0 && donvi != 0)
			{
				switch (chuc)
				{
				case 1:
				{printf("Muoi "); }
				break;
				case 2:
				{printf("Hai Muoi "); }
				break;
				case 3:
				{printf("Ba Muoi "); }
				break;
				case 4:
				{printf("Bon Muoi "); }
				break;
				case 5:
				{printf("Nam Muoi"); }
				break;
				case 6:
				{printf("Sau Muoi "); }
				break;
				case 7:
				{printf("Bay Muoi "); }
				break;
				case 8:
				{printf("Tam Muoi "); }
				break;
				case 9:
				{printf("Chin Muoi "); }
				break;
				}
				switch (donvi)
				{
				case 1:
				{printf("Mot "); }
				break;
				case 2:
				{printf("Hai "); }
				break;
				case 3:
				{printf("Ba "); }
				break;
				case 4:
				{printf("Bon "); }
				break;
				case 5:
				{printf("Lam "); }
				break;
				case 6:
				{printf("Sau "); }
				break;
				case 7:
				{printf("Bay "); }
				break;
				case 8:
				{printf("Tam "); }
				break;
				case 9:
				{printf("Chin "); }
				break;
				}
			}
		}
		else
		{
			if (chuc == 0 && donvi != 0)
			{
				switch (donvi)
				{
				case 1:
				{printf("Mot "); }
				break;
				case 2:
				{printf("Hai "); }
				break;
				case 3:
				{printf("Ba "); }
				break;
				case 4:
				{printf("Bon "); }
				break;
				case 5:
				{printf("Nam "); }
				break;
				case 6:
				{printf("Sau "); }
				break;
				case 7:
				{printf("Bay "); }
				break;
				case 8:
				{printf("Tam "); }
				break;
				case 9:
				{printf("Chin "); }
				break;
				}
			}
			else if (chuc != 0 && donvi == 0)
			{

				switch (chuc)
				{
				case 1:
				{printf("Muoi "); }
				break;
				case 2:
				{printf("Hai Muoi "); }
				break;
				case 3:
				{printf("Ba Muoi "); }
				break;
				case 4:
				{printf("Bon Muoi "); }
				break;
				case 5:
				{printf("Nam Muoi"); }
				break;
				case 6:
				{printf("Sau Muoi "); }
				break;
				case 7:
				{printf("Bay Muoi "); }
				break;
				case 8:
				{printf("Tam Muoi "); }
				break;
				case 9:
				{printf("Chin Muoi "); }
				break;
				}
			}
			else if (chuc != 0 && donvi != 0)
			{
				switch (chuc)
				{
				case 1:
				{printf("Muoi "); }
				break;
				case 2:
				{printf("Hai Muoi "); }
				break;
				case 3:
				{printf("Ba Muoi "); }
				break;
				case 4:
				{printf("Bon Muoi "); }
				break;
				case 5:
				{printf("Nam Muoi "); }
				break;
				case 6:
				{printf("Sau Muoi "); }
				break;
				case 7:
				{printf("Bay Muoi "); }
				break;
				case 8:
				{printf("Tam Muoi "); }
				break;
				case 9:
				{printf("Chin Muoi "); }
				break;
				}
				switch (donvi)
				{
				case 1:
				{printf("Mot "); }
				break;
				case 2:
				{printf("Hai "); }
				break;
				case 3:
				{printf("Ba "); }
				break;
				case 4:
				{printf("Bon "); }
				break;
				case 5:
				{printf("Lam "); }
				break;
				case 6:
				{printf("Sau "); }
				break;
				case 7:
				{printf("Bay "); }
				break;
				case 8:
				{printf("Tam "); }
				break;
				case 9:
				{printf("Chin "); }
				break;
				}

			}
		}
	}
	return 0;

}