Programmation pascal
Fermé
jumpy
-
18 juil. 2008 à 12:00
KX Messages postés 16668 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 17 mars 2023 - 18 juil. 2008 à 15:28
KX Messages postés 16668 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 17 mars 2023 - 18 juil. 2008 à 15:28
A voir également:
- Programmation pascal
- Turbo pascal download - Télécharger - Édition & Programmation
- My pascal - Télécharger - Édition & Programmation
- Programmation - Guide
- Application de programmation - Guide
- Logiciel programmation clé voiture gratuit - Forum Programmation
2 réponses
KX
Messages postés
16668
Date d'inscription
samedi 31 mai 2008
Statut
Modérateur
Dernière intervention
17 mars 2023
3 005
18 juil. 2008 à 15:28
18 juil. 2008 à 15:28
Je m'inspire de la procédure de aymoun888, pour donner un programme que j'ai testé :
La confiance n'exclut pas le contrôle
program SansNom;
const Nmax=31; // limite de integer
type tab=array[1..Nmax] of byte;
procedure convertion(var t:tab; n:integer);
var i:integer;
begin
for i:=1 to Nmax do t[i]:=2;
i:=1;
repeat
t[i]:=n mod 2;
n:=n div 2;
i:=i+1;
until( (n div 2=0) and (n mod 2=0));
end;
procedure Afficher(t:tab);
var i:integer;
begin
for i:=Nmax downto 1 do
if t[i]<2 then write(t[i]);
writeln;
end;
var t:tab;
begin
Convertion(t,5);
Afficher(t);
write('Fin du programme. Appuyer sur Entree'); readln;
end.--
La confiance n'exclut pas le contrôle
aymoun888
Messages postés
121
Date d'inscription
vendredi 4 avril 2008
Statut
Membre
Dernière intervention
31 octobre 2011
13
18 juil. 2008 à 14:45
18 juil. 2008 à 14:45
procedure convertion(var t:tab, n:integer)
var i:integer;
begin
i:=1;
repeat
t[i]:=n mod 2;
n:=n div 2;
i = i+1;
until(n div 2 = 0 and n mod 2 = 0)
end;
g pa testé le code, mai normalement ça marche
RQ: tab c un type défini au début de prog, c un tableau
var i:integer;
begin
i:=1;
repeat
t[i]:=n mod 2;
n:=n div 2;
i = i+1;
until(n div 2 = 0 and n mod 2 = 0)
end;
g pa testé le code, mai normalement ça marche
RQ: tab c un type défini au début de prog, c un tableau