Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by NguyenVietNamSon ( 5 years ago )
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<Windows.h>


int main()
{
chaylai:	
	long x, sochuso;
	printf("\nChuong trinh doc so thanh chu");
	printf("\nNhap so :");
	scanf("%d",&x);
	int temp2 = -1;
	printf("\n -----> ");
	if (x == 0)
	{
		sochuso = 1;
	}
	else
	{
		sochuso = log10(float(x)) + 1;
	}
	if (sochuso >= 1 && sochuso <=9)
	{
		// Đọc số 9 chữ số
		if (sochuso == 9)
		{
			int temp = x / 100000000;
			
			if (temp == 1)
			{
				printf("Mot tram ");
			}
			else if (temp == 2)
			{
				printf("Hai tram ");
			}
			else if (temp == 3)
			{
				printf("Ba tram ");
			}
			else if (temp == 4)
			{
				printf("Bon tram ");
			}
			else if (temp == 5)
			{
				printf("Nam tram ");
			}
			else if (temp == 6)
			{
				printf("Sau tram ");
			}
			else if (temp == 7)
			{
				printf("Bay tram ");
			}
			else if (temp == 8)
			{
				printf("Tam tram ");
			}
			else if (temp == 9)
			{
				printf("Chin tram ");
			}
			if (x % 100000000 == 0)
			{
				printf("trieu ");	
			}
			else
			{
				sochuso --;
				x = x % 100000000;
			}

		}
		// Đọc số 8 chữ số
		if (sochuso == 8)
		{
			int temp = x / 10000000;
			if (temp == 1)
			{
				printf("muoi ");
			}
			else if (temp == 2)
			{
				printf("hai muoi ");
			}
			else if (temp == 3)
			{
				printf("ba muoi ");
			}
			else if (temp == 4)
			{
				printf("bon muoi ");
			}
			else if (temp == 5)
			{
				printf("nam muoi ");
			}
			else if (temp == 6)
			{
				printf("sau muoi ");
			}
			else if (temp == 7)
			{
				printf("bay muoi ");
			}
			else if (temp == 8)
			{
				printf("tam muoi ");
			}
			else if (temp == 9)
			{
				printf("chin muoi ");
			}
			else if(temp == 0)
			{
				
				if ((int)log10(float(x)) + 1 == 6)
				{
					
				}
				else if ((int)log10(float(x)) + 1 == 7)
				{
					printf("le ");
				}
			}
			if (x % 10000000 == 0)
			{
				printf("trieu ");
			}
			else
			{
				sochuso --;
				x = x % 10000000;
			}
			temp2 = temp;
		}
		// Đọc số 7 chữ số
		if (sochuso == 7)
		{
			int temp = x / 1000000;
			if (temp == 1)
			{
				printf("mot trieu ");
			}
			else if (temp == 2)
			{
				printf("hai trieu ");
			}
			else if (temp == 3)
			{
				printf("ba trieu ");
			}
			else if (temp == 4)
			{
				printf("bon trieu ");
			}
			else if (temp == 5)
			{
				if(temp2 != -1 && temp2 != 0)
					printf("lam trieu ");
				else
					printf("nam trieu ");
			}
			else if (temp == 6)
			{
				printf("sau trieu ");
			}
			else if (temp == 7)
			{
				printf("bay trieu ");
			}
			else if (temp == 8)
			{
				printf("tam trieu ");
			}
			else if (temp == 9)
			{
				printf("chin trieu ");
			}
			else if(temp == 0)
			{
				printf("trieu ");
			}
			if (x % 1000000 == 0)
			{
			}
			else
			{
				sochuso --;
				x = x % 1000000;
			}
		}
		// Đọc số 6 chữ số
		if (sochuso == 6)
		{
			int temp = x / 100000;
			if (temp == 1)
			{
				printf("mot tram ");
			}
			else if (temp == 2)
			{
				printf("hai tram ");
			}
			else if (temp == 3)
			{
				printf("ba tram ");
			}
			else if (temp == 4)
			{
				printf("bon tram ");
			}
			else if (temp == 5)
			{
				printf("nam tram ");
			}
			else if (temp == 6)
			{
				printf("sau tram ");
			}
			else if (temp == 7)
			{
				printf("bay tram ");
			}
			else if (temp == 8)
			{
				printf("tam tram ");
			}
			else if (temp == 9)
			{
				printf("chin tram ");
			}
			else if(temp == 0)
			{
				if (((int)log10(float(x % 100000)) + 1 == 3) || ((int)log10(float(x % 100000)) + 1 == 2) || ((int)log10(float(x % 100000)) + 1 == 1))
				{
					
				}
				else
				{
					printf("khong tram ");
				}
				
			}
			if (x % 100000 == 0)
			{
				if (((int)log10(float(x % 100000)) + 1 == 3) || ((int)log10(float(x % 100000)) + 1 == 2) || ((int)log10(float(x % 100000)) + 1 == 1))
				{
					
				}
				else
				{
					printf("nghin ");
				}
			}
			else
			{
				sochuso --;
				x = x % 100000;
			}
		}
		// Đọc số 5 chữ số
		if (sochuso == 5)
		{
			int temp = x / 10000;
			if (temp == 1)
			{
				printf("muoi ");
			}
			else if (temp == 2)
			{
				printf("hai muoi ");
			}
			else if (temp == 3)
			{
				printf("ba muoi ");
			}
			else if (temp == 4)
			{
				printf("bon muoi ");
			}
			else if (temp == 5)
			{
				printf("nam muoi ");
			}
			else if (temp == 6)
			{
				printf("sau muoi ");
			}
			else if (temp == 7)
			{
				printf("bay muoi ");
			}
			else if (temp == 8)
			{
				printf("tam muoi ");
			}
			else if (temp == 9)
			{
				printf("chin muoi ");
			}
			else if(temp == 0)
			{
				if ((int)log10(float(x % 10000)) + 1 == 4)
				{
					printf("linh ");
				}
				else if (((int)log10(float(x % 10000)) + 1 == 3) || ((int)log10(float(x % 10000)) + 1 == 2) || ((int)log10(float(x % 10000)) + 1 == 1))
				{
					
				}
			}
			if (x % 10000 == 0)
			{
				printf("nghin ");	
			}
			else
			{
				sochuso --;
				x = x % 10000;
			}
			temp2 = temp;
		}
		// Đọc số 4 chữ số
		if (sochuso == 4)
		{
			int temp = x / 1000;
			if (temp == 1)
			{
				printf("mot nghin ");
			}
			else if (temp == 2)
			{
				printf("hai nghin ");
			}
			else if (temp == 3)
			{
				printf("ba nghin ");
			}
			else if (temp == 4)
			{
				printf("bon nghin ");
			}
			else if (temp == 5)
			{
				if(temp2 != -1 && temp2 != 0)
					printf("lam nghin ");
				else
					printf("nam nghin ");
			}
			else if (temp == 6)
			{
				printf("sau nghin ");
			}
			else if (temp == 7)
			{
				printf("bay nghin ");
			}
			else if (temp == 8)
			{
				printf("tam nghin ");
			}
			else if (temp == 9)
			{
				printf("chin nghin ");
			}
			else 
			{
				if (((int)log10(float(x % 100000)) + 1 == 3) || ((int)log10(float(x % 100000)) + 1 == 2) || ((int)log10(float(x % 100000)) + 1 == 1))
				{
					
				}
				if (((int)log10(float(x % 10000)) + 1 == 3) || ((int)log10(float(x % 10000)) + 1 == 2) || ((int)log10(float(x % 10000)) + 1 == 1))
				{
					
				}
				if (temp == 0)
				{
					printf("nghin ");
				}
			}
			if (x % 1000 == 0)
			{
			}
			else
			{
				sochuso --;
				x = x % 1000;
			}
		}
		// Đọc số 3 chữ số
		if (sochuso == 3)
		{
			int temp = x / 100;
			if (temp == 1)
			{
				printf("mot tram ");
			}
			else if (temp == 2)
			{
				printf("hai tram ");
			}
			else if (temp == 3)
			{
				printf("ba tram ");
			}
			else if (temp == 4)
			{
				printf("bon tram ");
			}
			else if (temp == 5)
			{
				printf("nam tram ");
			}
			else if (temp == 6)
			{
				printf("sau tram ");
			}
			else if (temp == 7)
			{
				printf("bay tram ");
			}
			else if (temp == 8)
			{
				printf("tam tram ");
			}
			else if (temp == 9)
			{
				printf("chin tram ");
			}
			else if(temp == 0)
			{
				printf("khong tram ");
			}
			if (x % 100 == 0)
			{
			}
			else
			{
				sochuso --;
				x = x % 100;
			}
		}
		// Đọc số 2 chữ số
		if (sochuso == 2)
		{
				int temp = x / 10;
			if (temp == 1)
			{
				printf("muoi ");
			}
			else if (temp == 2)
			{
				printf("hai muoi ");
			}
			else if (temp == 3)
			{
				printf("ba muoi ");
			}
			else if (temp == 4)
			{
				printf("bon muoi ");
			}
			else if (temp == 5)
			{
				printf("nam muoi ");
			}
			else if (temp == 6)
			{
				printf("sau muoi ");
			}
			else if (temp == 7)
			{
				printf("bay muoi ");
			}
			else if (temp == 8)
			{
				printf("tam muoi ");
			}
			else if (temp == 9)
			{
				printf("chin muoi ");
			}
			else if (temp == 0)
			{
				printf("linh ");
			}
			if (x % 10 == 0)
			{
			}
			else
			{
				sochuso --;
				x = x % 10;
			}
			temp2 = temp;
		}
		// Đọc số 1 chữ số
		if (sochuso == 1)
		{
			int temp = x % 10;
			if (temp == 1)
			{
				printf("mot");
			}
			else if (temp == 2)
			{
				printf("hai");
			}
			else if (temp == 3)
			{
				printf("ba");
			}
			else if (temp == 4)
			{
				printf("bon");
			}
			else if (temp == 5)
			{
				if(temp2 != -1 && temp2 != 0)
					printf("lam");
				else
					printf("nam");
			}
			else if (temp == 6)
			{
				printf("sau");
			}
			else if (temp == 7)
			{
				printf("bay");
			}
			else if (temp == 8)
			{
				printf("tam");
			}
			else if (temp == 9)
			{
				printf("chin");
			}
			else
			{
				printf("khong");
			}
		}
	}
	else
	{
		printf("So nhap vao khong hop le. Vui long kiem tra lai so tu 1 ---> 9 chu so!");
	}
	printf("\nNhap C de tiep tuc!");
	char n = getch();
		if (n == 'c' || n == 'C')
		{
			goto chaylai;
		}
	return 0;
}

 

Revise this Paste

Your Name: Code Language: