第五章上机报告.docVIP

  • 8
  • 0
  • 约3.88千字
  • 约 10页
  • 2017-05-16 发布于贵州
  • 举报
第五章上机报告

上机报告 第五章: 3. 原始程序: #includestdio.h main() { int m,n; int a,b,t; printf(Please input two number:\n); scanf(%d,%d,m,n); a=m*n; if(mn) t=m,m=n,n=m; for(;m%n!=0;) t=n,n=m%n,m=t; printf(The greatest common divisor=%d\n,n); b=a/n; printf(The least common multiple=%d\n,b); } 调试过程: 运行Compile:0 Warning 0 Errors. 使用F8 进行调试: 当输入15,25时,发现出现如图的错误: 显然与正确结果不符 Add Watch m; Add Watch n. 发现当输入15,25时,不进行for语句,直接跳过。 可知m%n==0,通过Watch中m,n的数值,发现if条件句中t=m,m=n,n=m处的错误,修改。 如图: 修改后继续进行Watch调试,得到如下结果: 调试成功。 最终程序为: #includestdio.h main() { int m,n; int a,b,t; printf(Please input two numbe

文档评论(0)

1亿VIP精品文档

相关文档