Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.

Paste

Pasted as C++ by registered user xujiayu ( 4 years ago )
#include <stdio.h>
#include <conio.h>
#include <math.h>
//bai doc so 
void nhapdulieu(int &n)
{
	printf("\nNhap so : ");
	scanf("%d",&n);
}
int tinhsoluongchuso(int n)
{    
	int soluongchuso = 0;
	while(n !=0)
	{
	    n /= 10;
		soluongchuso++;
	}
	soluongchuso--;
	return soluongchuso;
}

void daoso(int &n)
{
	int soluongchuso = tinhsoluongchuso(n);
	
	int tong = 0;
	while (n != 0)
	{
		tong += n % 10 * pow ((double)10,soluongchuso--);
		n/=10;
	}
	n = tong;
 
}
void dochangchuc(int sohangchuc)
{
	if(sohangchuc == 10)
	{
	   printf("MUOI");
	}
	if(sohangchuc == 20)
	{
	   printf("HAI MUOI");
	}
	if(sohangchuc == 30)
	{
	   printf("BA MUOI");
	}
	if(sohangchuc == 40)
	{
	   printf("BOM MUOI");
	}
	if(sohangchuc == 50)
	{
	   printf("Nam MUOI");
	}
	if(sohangchuc == 60)
	{
	   printf("Sau MUOI");
	}
	if(sohangchuc == 70)
	{
	   printf("Bay MUOI");
	}
	if(sohangchuc == 80)
	{
	   printf("Tam MUOI");
	}
	if(sohangchuc == 90)
	{
	   printf("Chin MUOI");
	}
}
void docchuso (int sochuso)
{   

	if(sochuso == 1)
	{
	   printf(" MOT ");
	}
	else if (sochuso == 2)
	{
		printf(" Hai ");
	}
	else if (sochuso == 3)
	{
		printf(" Ba ");
	}
	else if (sochuso == 4)
	{
		printf(" Bon ");
	}
	else if (sochuso == 5)
	{
		printf(" Nam ");
	}
	else if (sochuso == 6)
	{
		printf(" Sau ");
	}
	else if (sochuso == 7)
	{
		printf(" Bay ");
	}
	else if (sochuso == 8)


	{
		printf(" Tam ");
	}
	else if (sochuso == 9)
	{
		printf(" Chin ");
	}
	else if (sochuso == 10)
	{
		printf(" Muoi ");
	}
}
 
void docphuam (int sochusoconlai)
{

	if(sochusoconlai == 1)
	{
	   printf(" Muoi ");
	}
	else if(sochusoconlai == 2)
	{
		printf("Tram");
	}
	else if(sochusoconlai == 3)
	{
		printf("Nghin");
	}
	else if(sochusoconlai == 4)
	{
		printf("Muoi ");
	}
	else if(sochusoconlai == 5)
	{
		printf("Tram ");
	}
	else if(sochusoconlai == 6)
	{
		printf("Trieu");
	}
	else if(sochusoconlai == 7)
	{
		printf("Muoi Trieu");
	}
	else if(sochusoconlai == 8)
	{
		printf("Tram Trieu");
	}
	else if(sochusoconlai == 9)
	{
		printf("ty");
	}
	
}

 
/*
1234
b1 dao thanh 4321
b2 %10 lay so cuoi roi doc len 
b3 n chia 10 de loai bo so da doc 
b4 la sau khi loai bo dem coi con bao nhieu chu so roi set cach doc phu am (tram , trieu, nghin)
 
*/

void docsochuc (int &n)
{
	daoso(n);
	dochangchuc(n %10 *10);
	n /= 10;
	
}

	

int main()
{
	 int a;
	 nhapdulieu(a);

	docso(a);

	


	


	

	getch();
	return 0;



}

 

Revise this Paste

Parent: 118634
Your Name: Code Language: