最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

如何证明欧几里德算法的伪代码?

SEO心得admin82浏览0评论
本文介绍了如何证明欧几里德算法的伪代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

A(n,m): { if n==m, return(n) else { t = 1; while {n and m are divisible by 2} { t=2t, n = n/2, m=m/2 }; while {n is divisible by 2} n = n/2; while {m is divisible by 2} m=m/2; if n==m, return( t * n) else { k = m - n; while {k is divisible by 2} k=k/2; return( t * A( min(n,m), |k| ) ) } } }

推荐答案

通过形式验证证明代码确实是一项复杂的任务。 接受代码的常用方法因为'足够好'在一组已知输入上运行它,然后将其输出与预期输出进行比较。您可以通过将伪代码转换为实际程序来轻松实现。 Proving code by formal verification is really a complex task. A common way to accept code as 'good enough' is running it on a known set of inputs and then comparing its outputs with the expected ones. You might easily do that by translating the pseudo code into an actual program.

发布评论

评论列表(0)

  1. 暂无评论