Skip to content

Instantly share code, notes, and snippets.

@charlesdarkwind
Last active October 11, 2018 17:41
Show Gist options
  • Save charlesdarkwind/1375af3bbaef4c983e24e10d1d11ba73 to your computer and use it in GitHub Desktop.
Save charlesdarkwind/1375af3bbaef4c983e24e10d1d11ba73 to your computer and use it in GitHub Desktop.
Exercice pseudoCode
6. Liste de doublons d'une liste non ordonee
Entree: monTableau: int[]
Sortie: void
Procedure: listerDoublons(monTableau)
DEBUT
POUR i = 0 a monTableau.length - 1
POUR j = 0 a monTableau.length - 1
SI ( i != j && monTableau[i] == monTableau[j] )
afficher( monTableau[i] );
FINSI
FINPOUR
FINPOUR
RETOURNER doublons;
FIN
7. Palindrome
Entree: mot: tableau
Sortie: estPalindrome: boolean
Procedure: checkerSiPalindrome(mot)
DEBUT
POUR i = 0 a mot.length - 1
SI ( mot.length - (1 + i) != i && mot[i] != mot[mot.length - (1 + i)] )
RETOURNER faux;
FINSI
FINPOUR
RETOURNER vrai;
FIN
8. X a la puissance n
Entres: x: entier, n: entier
Sortie: y: entier
Procedure: calculerPuissance(x, n)
DEBUT
absN = abs(n);
y = x;
SI (n == 0)
RETOURNER 1;
FINSI
POUR i = 1 a absN
y * x;
FINPOUR
SI (n > 0)
RETOURNER y;
SINON
RETOURNER 1 / y;
FINSI
FIN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment