TC下的精确除法(转贴)
#include <stdio.h>#define lennum 64
int res;
long process(long m,long n)
{
long i,k;
i=1;
k=m/n;
m-=(n*k);
printf("%d.",k);
do
{
m*=10;
res=m/n;
m-=(n*res);
printf("%d",res);
i++;
}while(i<=lennum);
}
int main()
{
int m,n;
long process(long,long);
printf("\nProcess M/N currently!");
start: printf("\nInput M:");
scanf("%ld",&m);
printf("\nInput N:");
scanf("%ld",&n);
if (n==0) {printf("\nN can't be 0!!");getch();goto start;}
process(m,n);
getch();
}
页:
[1]