Algorithm studying
来源:互联网 发布:伴随矩阵的性质 编辑:程序博客网 时间:2024/05/22 17:12
//Euclid's algorithm
//Euclid(m,n),m>n
//input:two integers m,n which are not less than 0 and not all 0;
//output:the greates common divisor of m,n
while n!=0 do
r←m mod n
m←n
n←r
return m
___________________________________________________________________________________________________________________________________
//Sieve of Eratosthenes
//Sieve(n)
//input:an integer n>1
//output:list of primes less than or equal to n
for p←2 to n do A[p]←p
for p←2 to └ √n ┘do
if A[p]!=0
j ←p*p
while j<=n
A[j]←0
j←j+p
i←0
for p←2 to n do
if A[p]!=0
L[i]←A[p]
i←i+1
return L
____________________________________________________________________________________________________________________________________
MatrixMultipication
//input: two n-by-n matrices A and B
//output:Matrix C=AB
for i←0 to n-1 do
for j←0 to n-1 do
C[i,j]←0.0
for k←0 to n-1 do
C[i,j]←C[i,j]+A[i,k]*B[k,j]
return C
____________________________________________________________________________________________________________________________________
- Algorithm studying
- Algorithm
- Algorithm
- algorithm
- algorithm
- algorithm
- algorithm
- algorithm
- Algorithm
- Algorithm
- algorithm
- Algorithm
- Algorithm
- algorithm
- algorithm
- <algorithm>
- Studying English
- java studying
- 【Some】【WebSite】Fun with Android Shaders and Filters
- Linux下用半同步/半异步实现进程池
- PHP学生笔记:PHP中的面向对象编程
- 数据中心网络虚拟化技术 概要
- 今天开通CSDN,记录DBA学习之路
- Algorithm studying
- poj 3259 wormholes AC代码(负权环判断, Bellmanford)
- IntelJ IDEA 快捷键全图
- Linux操作系统下三种配置环境变量的方法
- Android Studio中几个非常有用的工具
- Android实现用户引导界面
- 1029. 旧键盘(20)
- 将ant执行的日志输出到文本中
- 拟牛顿法/Quasi-Newton,DFP算法/Davidon-Fletcher-Powell,及BFGS算法/Broyden-Fletcher-Goldfarb-Shanno