Traduction en programme C

HAFIDHOU -  
[Dal] Messages postés 6205 Date d'inscription   Statut Contributeur Dernière intervention   -
Bonjour,
Qui peut me traduire ce programme Pascal en programme C?
Voici le programme:
Pascal

program cryptage?
uses wincrt?
var c:char?
e,m:integer?
begin writeln('entrer un caractere')?
readln(c)?
if c in ['A'..'B'] then
c:=pred (c)?
else if c in ['a'..'z'] then
c:= succ (c)
else if c in ['0'..'9'] then
begin
val(c,m,e)?
c:=chr(ord(9)­m)?
end
else
c:=succ(succ(c)) ?
writeln(c) ?
end.

1 réponse

[Dal] Messages postés 6205 Date d'inscription   Statut Contributeur Dernière intervention   1 105
 
Salut,

ton programme Pascal, cela ne serait pas plutôt cela :

program truc;

uses
Crt;

var
c: char;
e, m: integer;
begin
Writeln('entrer un caractere');
Readln(c);
if c in ['A'..'B'] then
c := pred(c)
else if c in ['a'..'z'] then
c := succ(c)
else if c in ['0'..'9'] then
begin
val(c, m, e);
c := chr(Ord(9) - m);
end
else
c := succ(succ(c));
Writeln(c);
end.

Dal
0
Miura564 Messages postés 13404 Date d'inscription   Statut Membre Dernière intervention   1 509
 
c'est clairement plus lisible...
0
[Dal] Messages postés 6205 Date d'inscription   Statut Contributeur Dernière intervention   1 105
 
oui... et il ya des chances que
  if c in ['A'..'B'] then
soit en réalité
if c in ['A'..'Z'] then
0