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>

//viet chuong trinh tra ve so dao
void nhapdulieu(int &n)
{
	 printf("\nHay nhap vao so nguyen: ");
	 scanf("%d",&n);
}
int travesodao(int n)
{
	int soluongchuso = log10((double)n);
	int tong = 0;
	while (n != 0)
	{
		 tong += n % 10 * pow((double)10, soluongchuso--);
		 n /= 10;
		
	}
	 return tong;
}

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

	int tong = travesodao(a);

	printf("\nso dao cua so a la %d",tong);

	getch();
	return 0;



}

 

Revise this Paste

Your Name: Code Language: