Comparatif : Algorithme - Python - Java
1■■ Algorithme (pseudo-code)
Algorithme SommeProduitDifference
DEBUT
Variable a, b, somme, produit, difference : Entier
Ecrire "Entrez le premier nombre (a) : "
Lire a
Ecrire "Entrez le deuxième nombre (b) : "
Lire b
somme ← a + b
produit ← a * b
difference ← a - b
Ecrire "Somme = ", somme
Ecrire "Produit = ", produit
Ecrire "Différence = ", difference
FIN
2■■ Version Python
a = int(input("Entrez le premier nombre (a) : "))
b = int(input("Entrez le deuxième nombre (b) : "))
somme = a + b
produit = a * b
difference = a - b
print("\nRésultats :")
print("Somme =", somme)
print("Produit =", produit)
print("Différence =", difference)
3■■ Version Java
import [Link];
public class SommeProduitDifference {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Entrez le premier nombre (a) : ");
int a = [Link]();
[Link]("Entrez le deuxième nombre (b) : ");
int b = [Link]();
int somme = a + b;
int produit = a * b;
int difference = a - b;
[Link]("\nRésultats :");
[Link]("Somme = " + somme);
[Link]("Produit = " + produit);
[Link]("Différence = " + difference);
[Link]();
}
}