- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
module Main:
program factorial:
algorithm factorial:
description of the algorithm:
factorial of n is the algorithm that calculates the product of all the positive integers less than or equal to n.
end of description of the algorithm.
example of usage of the algorithm:
var1 is equal to call algorithm with parameter n which is equal to 5;
begin of a comment:
var1 is now1 120 = 5*4*3*2*1.
end of a comment.
end of example of usage of the algorithm.
description of author of the algorithm:
name: John.
surname: Smith.
date of writing of the algorithm: 2009.
end of description of author of the algorithm.
properties of the algorithm:
callable from other modules.
callable from this module.
can be used in expressions.
end of properties of the algorithm.
parameters of the algorithm:
data n: type is positive integer.
end of parameters of the algorithm.
variables of the algorithm:
data res: type is positive integer.
data now1: type is positive integer.
end of variables of the algorithm.
initialization of the variables of the algorithm:
res is equal to 1.
now1 is equal to n.
end of initialization of the variables of the algorithm.
begin of the algorithm:
cycle: while now1 is not 1, repeat:
res is equal to multiply res by now1.
now1 is equal to subtract 1 from now1.
end of cycle.
result of the algorithm is res
end of the algorithm.
algorithm main:
description of the algorithm:
main algorithm that shows the factorial of the inputted number.
end of description of the algorithm.
example of usage of the algorithm:
end of example of usage of the algorithm.
description of author of the algorithm:
name: John.
surname: Smith.
date of writing of the algorithm: 2009.
end of description of author of the algorithm.
properties of the algorithm:
callable from the system.
end of properties of the algorithm.
parameters of the algorithm:
data arguments: type is array of strings.
end of parameters of the algorithm.
variables of the algorithm:
end of variables of the algorithm.
initialization of the variables of the algorithm:
end of initialization of the variables of the algorithm.
begin of the algorithm:
call algorithm writeInteger with parameter str which is equal to
call algorithm factorial with parameter n which is equal to
call algorithm readInteger without parameters.
result of the algorithm is 0.
end of the algorithm.
Небольшой ответ набирающему популярность WCT. Новый язык программирования LOOOONG:
- Отступы обязательны.
- Все блоки в функциях ("алгоритмах") обязательны.
- блоки нужно записывать именно в таком порядке.
- Имена параметров необходимо помнить, когда вызываешь "алгоритм".
- Ключевых слов ОЧЕНЬ МНОГО.