声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1501|回复: 0

[C/C++] TC下的精确除法(转贴)

[复制链接]
发表于 2007-6-21 01:39 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
  1. #include <stdio.h>
  2. #define lennum 64
  3. int res[lennum];
  4. long process(long m,long n)
  5. {
  6. long i,k;
  7. i=1;
  8. k=m/n;
  9. m-=(n*k);
  10. printf("%d.",k);
  11. do
  12. {
  13.   m*=10;
  14.   res[i]=m/n;
  15.   m-=(n*res[i]);
  16.   printf("%d",res[i]);
  17.   i++;
  18. }while(i<=lennum);
  19. }
  20. int main()
  21. {
  22. int m,n;
  23. long process(long,long);
  24. printf("\nProcess M/N currently!");
  25. start: printf("\nInput M:");
  26. scanf("%ld",&m);
  27. printf("\nInput N:");
  28. scanf("%ld",&n);
  29. if (n==0) {printf("\nN can't be 0!!");getch();goto start;}
  30. process(m,n);
  31. getch();
  32. }
复制代码

评分

1

查看全部评分

回复
分享到:

使用道具 举报

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-10 20:36 , Processed in 0.075582 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表