first commit
This commit is contained in:
10
examples/factorielle.spf
Normal file
10
examples/factorielle.spf
Normal file
@ -0,0 +1,10 @@
|
||||
entier nombre = 5;
|
||||
entier factorielle;
|
||||
|
||||
factorielle = 1;
|
||||
tant que nombre > 0 faire {
|
||||
factorielle = factorielle * nombre;
|
||||
nombre = nombre - 1;
|
||||
}
|
||||
|
||||
afficher "La factorielle vaut", factorielle;
|
11
examples/maximum.spf
Normal file
11
examples/maximum.spf
Normal file
@ -0,0 +1,11 @@
|
||||
liste nombres = [1, 8, 3, 6];
|
||||
entier maximum;
|
||||
|
||||
maximum = nombres[1];
|
||||
pour chaque entier nombre dans nombres faire {
|
||||
si nombre > maximum alors {
|
||||
maximum = nombre;
|
||||
}
|
||||
}
|
||||
|
||||
afficher "Le maximum dans", nombres, "est", maximum;
|
14
examples/monotone.spf
Normal file
14
examples/monotone.spf
Normal file
@ -0,0 +1,14 @@
|
||||
liste nombres = [3, 3, 6, 7, 8];
|
||||
booléen monotone = vrai;
|
||||
|
||||
pour chaque entier position dans [1:taille nombres - 1] faire {
|
||||
si nombres[position] > nombres[position + 1] alors {
|
||||
monotone = faux;
|
||||
}
|
||||
}
|
||||
|
||||
si monotone alors {
|
||||
afficher "La liste", nombres, "est monotone";
|
||||
} sinon {
|
||||
afficher "La liste", nombres, "n'est pas monotone";
|
||||
}
|
21
examples/mots.spf
Normal file
21
examples/mots.spf
Normal file
@ -0,0 +1,21 @@
|
||||
texte phrase = "Bonjour à tout le monde";
|
||||
texte mot = "";
|
||||
liste mots = [];
|
||||
|
||||
pour chaque texte caractère dans phrase faire {
|
||||
si caractère vaut " " alors {
|
||||
si taille mot > 0 alors {
|
||||
ajouter mot dans mots;
|
||||
mot = "";
|
||||
}
|
||||
} sinon {
|
||||
mot = mot + caractère;
|
||||
}
|
||||
}
|
||||
|
||||
# Potentiel dernier mot
|
||||
si taille mot > 0 alors {
|
||||
ajouter mot dans mots;
|
||||
}
|
||||
|
||||
afficher mots;
|
Reference in New Issue
Block a user