Se connecter avec
S'enregistrer | Connectez-vous

table de vérité

Dernière réponse : dans Programmation

Comment faire pour afficher la table de vérité de l'expression booléenne suivante :
A and (B or C)

J'ai commencé qqch. Pouvez vous me dire ce que vous en pensez?

with ada.text_io, ada.integer_text_io;
A,B,C : boolean;
if A = true then
if B = true then
ada.text_io.put("A and(B or C)=");ada.text_io.put("vrai");
else
if C = true then
ada.text_io.put("A and(B or C)=");ada.text_io.put("vrai");
else
ada.text_io.put("A and(B or C)=");ada.text_io.put("faux");
end if;
end if;
else
ada.text_io.put("A and(B or C)=");ada.text_io.put("faux");
end if;

Merci

Autres pages sur : table verite

Lassé par la pub ? Créez un compte

si j'ai bien compris ce que tu veux, c'est afficher la sortie de ta fonction d'après les paramptres A,B et C.

alors il te suffit de faire cela :

  1. with Ada.Text_IO; use Ada.Text_IO;
  2.  
  3. procedure Main is
  4.  
  5. A,B,C : Boolean;
  6.  
  7. begin
  8. if A and (B or C) then
  9. put("Vrai");
  10. else
  11. put("Faux");
  12. end if;
  13. end Main;

J'ai modifié mon programme :

with ada.text_io, ada.integer_text_io;
A,B,C : boolean;
begin
ada.text_io.put("A"); ada.text_io.put("B"); ada.text_io.put("C");
ada.text_io.put("A and (B or C");
ada.text_io.new_line;
for A loop
for B loop
for C loop
if A then ada.text_io.put("1"); else ada.text_io.put("0"); end if;
if B then ada.text_io.put("1"); else ada.text_io.put("0"); end if;
if C then ada.text_io.put("1"); else ada.text_io.put("0"); end if;
if A and (B or C) then ada.text_io.put("1"); else ada.text_io.put("0");
end if;
ada.text_io.new_line;
end;
end;
end;
end;

Qu'en pensez vous?

J'ai modifié mon programme :

with ada.text_io, ada.integer_text_io;
A,B,C : boolean;
begin
ada.text_io.put("A"); ada.text_io.put("B"); ada.text_io.put("C");
ada.text_io.put("A and (B or C");
ada.text_io.new_line;
for A loop
for B loop
for C loop
if A then ada.text_io.put("1"); else ada.text_io.put("0"); end if;
if B then ada.text_io.put("1"); else ada.text_io.put("0"); end if;
if C then ada.text_io.put("1"); else ada.text_io.put("0"); end if;
if A and (B or C) then ada.text_io.put("1"); else ada.text_io.put("0");
end if;
ada.text_io.new_line;
end;
end;
end;
end;

Qu'en pensez vous?

J'ai modifié mon programme :

with ada.text_io, ada.integer_text_io;
A,B,C : boolean;
begin
ada.text_io.put("A"); ada.text_io.put("B"); ada.text_io.put("C");
ada.text_io.put("A and (B or C");
ada.text_io.new_line;
for A loop
for B loop
for C loop
if A then ada.text_io.put("1"); else ada.text_io.put("0"); end if;
if B then ada.text_io.put("1"); else ada.text_io.put("0"); end if;
if C then ada.text_io.put("1"); else ada.text_io.put("0"); end if;
if A and (B or C) then ada.text_io.put("1"); else ada.text_io.put("0");
end if;
ada.text_io.new_line;
end;
end;
end;
end;

Qu'en pensez vous?
Lassé par la pub ? Créez un compte
Tom's guide dans le monde