• Aucun résultat trouvé

Corrigés bac pratique informatique

N/A
N/A
Protected

Academic year: 2022

Partager "Corrigés bac pratique informatique"

Copied!
1
0
0

Texte intégral

(1)Corrigés bac pratique informatique Sections Science de l’informatique 21 Mai 2008(14h30). Corrigé Sujet le 21 Mai 2008 à 14h30. ap. ie. .c. om. end; var nb:word;ch:string; begin assign(fr,'c:\bac2008\round.dat'); rewrite(fr); assign(fnr,'c:\bac2008\non_round.dat'); rewrite(fnr); reset(f); while(not(eof(f)))do begin read(f,nb); if(rond(nb))then begin write(fr,nb); ch:=conv_bin(nb); writeln('Le nombre ',nb,' est round car ',nb,'=(',ch,')2'); end else write(fnr,nb); end; close(fr); close(fnr); close(f); end; {*********** programme principal **********} begin repeat write('Saisir le nombre des entiers: '); readln(n); until( n in [10..100]); creation(f,n); clrscr;writeln('-----------------------------------------'); writeln; writeln('---- LISTE DES ENTIERS NATURELS RONDS ----'); writeln; writeln('------------------------------------------'); writeln; eclat(f,fr,fnr);end.. og ag. cp ed. program sujet3; uses wincrt; type fnat= file of word; var f,fr,fnr:fnat;n:integer; procedure creation(var f:fnat;n:integer); var i:integer;m:word; begin assign(f,'c:\bac2008\naturels.dat'); rewrite(f); for i:=1 to n do begin repeat write('saisir un entier naturel: '); readln(m); until (m >=0)and (m<32000); write(f,m); end; close(f); end; function conv_bin(dec:word):string; var r:word; ch_bin,chr:string[20]; begin ch_bin:=''; repeat r:=dec mod 2; str(r,chr); ch_bin:=chr+ch_bin; dec:=dec div 2 until (dec =0); conv_bin:=ch_bin; end; function rond(nb:word):boolean; var n0,n1,i:integer;ch:string; begin ch:=conv_bin(nb); n0:=0;n1:=0; for i:=1 to length(ch)do if(ch[i]='0')then n0:=n0+1 else n1:=n1+1; if(n0=n1)then rond:=true else rond:=false;. Page 1/2.

(2)

Références

Documents relatifs

Correction proposée par Mme Lamia & Mme Hana... Correction proposée par Mme Lamia &

Corrigés Bac pratique Informatique Section Sciences de l'informatique 21 mai 2009 8h30, 10h30 Jeudi 21 mai 2009 à 8h30 program sup_prem; uses wincrt; var n:longint; f:text;

The classical convergence proof (see e. [Greenberg] or [Schrijver]) is based on the observation that the constant term b in program (12) lexicographically increase at each step of

[r]

[r]

Lecture contrôlée d’un entier Procedure lecture ( var n :integer);.

[r]

[r]