Probléme Algorithme
gui175
Messages postés
6
Date d'inscription
Statut
Membre
Dernière intervention
-
ccm81 Messages postés 10909 Date d'inscription Statut Membre Dernière intervention -
ccm81 Messages postés 10909 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
j'ai crée un petit algorithme en pascal pour convertir un fichier binaire en décimal mais j'ai un problème et je vois pas d'où sa peux venir, si vous avait une idée merci :)
var dec,m,k,l,chiffre:integer;
bin:string;
begin
write('entree un valeurs binaire : ');readln(bin);
dec:=0;
l:= length(bin);
m:=1;
for k := 1 to l
do
if bin [l-k+1] = '0'
then
begin
chiffre:=0
end
else
begin
chiffre:=1
end;
dec:= dec+chiffre*m;
m:=m*2;
writeln;writeln;
writeln('la valeurs decimal es : ',dec);
readln;
end.
j'ai crée un petit algorithme en pascal pour convertir un fichier binaire en décimal mais j'ai un problème et je vois pas d'où sa peux venir, si vous avait une idée merci :)
var dec,m,k,l,chiffre:integer;
bin:string;
begin
write('entree un valeurs binaire : ');readln(bin);
dec:=0;
l:= length(bin);
m:=1;
for k := 1 to l
do
if bin [l-k+1] = '0'
then
begin
chiffre:=0
end
else
begin
chiffre:=1
end;
dec:= dec+chiffre*m;
m:=m*2;
writeln;writeln;
writeln('la valeurs decimal es : ',dec);
readln;
end.
A voir également:
- Probléme Algorithme
- Logiciel algorithme euromillion - Télécharger - Loisirs créatifs
- Logiciel algorithme gratuit - Télécharger - Édition & Programmation
- Algorithme euromillion excel gratuit - Forum Algorithmes / Méthodes
- Algorithme ajout rapide snapchat - Forum Snapchat
- Ajout rapide snap - Forum Snapchat
3 réponses
bonsoir
une petite fonction qui convertit un "string binaire" en "word décimal"
bonne suite
une petite fonction qui convertit un "string binaire" en "word décimal"
program bindec; uses crt; var bin : string; dec : word; function bintodec(b:string):word; begin if length(b) = 1 then bintodec := ord(b[1])-48 else bintodec := ord(b[length(b)])-48+2*bintodec(copy(b,1,length(b)-1)); end; begin write('b = ');readln(bin); dec := bintodec(bin); writeln('d = ',dec) end.
bonne suite