Pierre, feuille, ciseaux quelques pb

duvduv Messages postés 119 Statut Membre -  
 profil.de blog -
Bonjour,

je suis debutant en pascal. j'aimerais faire un programme "pierre, feuille, ciseaux".
voila mon code:

program chifoumi;
var
objet1 : char;
objet2 : char;
arbitre : string;

begin
writeln('joueur1:');
readln(objet1);
writeln('joueur2:');
readln(objet2);

if objet1=objet2 then
begin
writeln('égalité: ',objet1);
end

else

arbitre:=objet1+objet2;

if arbitre='fp' then
begin
writeln('f : gagne');
end
else
if arbitre='cp' then
begin
writeln('p : gagne');
end
else
if arbitre='cf' then
begin
writeln('c : gagne');
end;
end.

mes questions: j'aimerais dire si objet1 et objet2 valent f,p,c alors...
pour pouvoir rajouter un "sinon" qd objet1 et/ou objet2 sont differents de f,p,c et renvoyer une erreur.

moi j'ecris if ojet1 and objet2 in ['f','c','p'] mais evidement ca marche pas

deuxieme pb j'ecris if arbitre='fp' then
j'aimerais avoir la reciproque : if arbitre='fp' ou 'pf'
comment qu'on fait?

merci d'avance
duvduv

3 réponses

Amaranthe
 
Bonjour,

mes questions: j'aimerais dire si objet1 et objet2 valent f,p,c alors...
pour pouvoir rajouter un "sinon" qd objet1 et/ou objet2 sont differents de f,p,c et renvoyer une erreur.

moi j'ecris if ojet1 and objet2 in ['f','c','p'] mais evidement ca marche pas

=> If objet1 in ['f','c','p'] AND objet2 in ['f','c','p']

deuxieme pb j'ecris if arbitre='fp' then
j'aimerais avoir la reciproque : if arbitre='fp' ou 'pf'
comment qu'on fait?

idem... If arbitre ='fp' OR arbitre = 'pf'

Cordialement,

Amaranthe
0
duvduv Messages postés 119 Statut Membre 3
 
salut amaranthe,

j'ai essaye pour le "or" il me renvoi l'erreur: Error: Operation "or" not supported for types "ShortString" and "ShortString"

et pour "and": Error: Operation not implemented for sets

c'est quoi le pb?
0
profil.de blog
 
pour t'aider va sur le site(blog)www.perso-dofus-blog.skyrock.com (va vers le bas )
0