Nomenclàtor de notació algorísmica
Introducció
En aquesta unitat anirem afegint diferents recursos que us poden ser útils a l'hora de dissenyar algorísmic. De moment teniu un recull de la notació algorísmica que utilitzem.
Resum Notació algorísmica
Llegenda:
Negreta s’utilitza per les paraules clau.
Cursiva cal ser substituida per l'identificador definit per l’usuari (nom de la variable, del tipus, etc.); no significa que els identificadors vagin en cursiva en els algorismes.
Català s’utilitza per a la descripció d’intruccions.
Tipus bàsics:
integer
char
real
boolean
string
Declaració de tipus:
type
typeName = declaració del tipus
end type
Declaració de constants:
const
CONST_NAME: type = valor;
end const
Declaració de variables:
var
varName: tipus de la variable;
end var
Declaració de tuples:
type
typeName = record
fieldName: tipus del camp;
end record
end type
Declaració de vectors:
var
vectorName: vector[longitud] of tipus del camp;
end var
Condicional:
if expressió condicional then
bloc d’instruccions
end if
o
if expressió condicional then
bloc d’instruccions
else
bloc d’instruccions
end if
Iteració:
while expressió condicional do
bloc d’instruccions
end while
o
for varName := valor inicial to valor final [step valor d'increment/decrement] do
bloc d’instruccions
end for
Classes de paràmetres:
in
out
inout
Funció:
function functionName (parName1: tipus del paràmetre, ..., parNameN: tipus del paràmetre): tipus del retorn
bloc d’instruccions
end function
Acció:
action actionName (classe del paràmetre parName1: tipus del paràmetre, ..., classe del paràmetre parNameN: tipus del paràmetre)
bloc d’instruccions
end action
Algorisme:
algorithm algorithmName
bloc d’instruccions
end algorithm
Declaració de punters:
var
varName: pointer to tipus del camp;
end var
Operadors lògics:
and
or
not
Operador d'assignació:
:=
Operadors de comparació:
=
≠
<
>
≤
≥
Constants booleanes:
true
false
Funcions i accions d’entrada/sortida:
function readInteger(): integer;
function readReal(): real;
function readChar(): char;
function readString(): string;
function readBoolean(): boolean;
action writeInteger(in varName: integer);
action writeReal(in varName: real);
action writeChar(in varName: char);
action writeString(in varName: string);
action writeBoolean(in varName: boolean);
Funcions de canvi de tipus:
function integerToReal(varName: integer): real;
function realToInteger(varName: real): integer;
function charToCode(varName: char): integer;
function codeToChar(varName: integer): char;