Pierre, feuille, ciseaux quelques pb
duvduv
Messages postés
119
Statut
Membre
-
profil.de blog -
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
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
A voir également:
- Pierre, feuille, ciseaux quelques pb
- Télécharger outil capture d'écran ciseaux - Télécharger - Capture d'écran
- Pierre eclat pokemon platine - Forum Jeux vidéo
- Wifipass pierre et vacances login - Forum Réseaux sociaux
- Feuille de score belote excel - Forum Excel
- Feuille diddl la plus rare ✓ - Forum Graphisme
3 réponses
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
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