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 s’utilitza per identificadors definits per l’usuari (noms de variables, tipus, etc.).
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
constName: type = expressió;
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:= expressió1 to expressió2 [step expressió3] do
bloc d’instruccions
end for
Classe de paràmetres:
in
out
inout
Funció:
function functionName (classe del paràmetre parName1: tipus del paràmetre, ..., classe 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 i constants:
and
or
not
true
false
Funcions i accions d’entrada/sortida:
function readInteger(): integer;
function readReal(): real;
function readChar(): char;
function readString(): string;
function readBoolean(): boolean;
action writeInterger(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;