Giai_bai_tap_tin_hoc_11_6075_10443540

Embed Size (px)

Citation preview

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    1/29

    Great by: Nguyn Trng Hong Email: [email protected]

    Gii BiGii BiGii BiGii BiTp TinTp TinTp TinTp Tin

    Hc 11Hc 11Hc 11Hc 11

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    2/29

    Great by: Nguyn Trng Hong Email: [email protected]

    Chng 1Chng 1Chng 1Chng 1::::t s khi nim v lp trnh v ngn ng lp trnht s khi nim v lp trnh v ngn ng lp trnht s khi nim v lp trnh v ngn ng lp trnht s khi nim v lp trnh v ngn ng lp trnh

    Bi tpBi tpBi tpBi tp1.Ngi ta phi xy dng ngn nglp trnh bc cao v- Ngn ng lp trnh bc cao gn gi vi tnhin hn, thun tin cho

    ng o ngi lp trnh.- Ngn ng lp trnh bc cao ni chung khng ph thuc vo loi my,

    cng mt chng trnh c th thc hin nhiu my khc nhau.- Chng trnh vit bng ngn ngbc cao d hiu, d hiu chnh v d

    nng cp hn.- Ngn nglp trnh bc cao cho php lm vic vi nhiu kiu dliu v

    cch t chc dliu a dng, thun tin cho m t thut ton.2.Chng trnh dch l chng trnh c bit, c chc nng chuyn i

    chng trnh c vit trn ngn nglp trnh bc cao thnh chngtrnh thc hin c trn my tnh.

    3.- Bin dch: duyt, kim tra, pht hin li, xc nh chng trnh ngun

    c dch c khng. Dch ton b chng trnh ngun thnh mtchng trnh ch c th thc hin trn my v c th lu trli sdng v sau khi cn.

    - Thng dch: ln lt dch tng cu lnh ra ngn ngmy ri thc hinngay cu lnh va dch c hoc thng bo li nu khng dch c.

    4.Cc im khc nhau gia tn dnh ring v tn chun: tn dnh ringkhng c dng khc vi ngha xc nh, tn chun c th dng vi ngha khc.

    5.ng: tamgiac, bai5a, xemxonxiu_ngu...6.C: 6,23 6.23E: A20 tn cha c gi trG: 64 + H: C CI: TRUE true l hng logic.

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    3/29

    Great by: Nguyn Trng Hong Email: [email protected]

    Chng 2Chng 2Chng 2Chng 2::::

    hng trnh n ginhng trnh n ginhng trnh n ginhng trnh n ginBi Thc Hnh S 1Bi Thc Hnh S 1Bi Thc Hnh S 1Bi Thc Hnh S 1--------------------------------------------------------------------********************--------------------------------------------------------------------

    1. Skhc nhau gia hng c t tn v tn bin: Gi tr ca hng c ttn khng thay i khi thc hin chng trnh cn gi tr ca bin cth thay i ti tng thi im thc hin chng trnh.

    2. Khai bo bin nhm nhng mc ch sau:- Xc nh kiu ca bin. Trnh dch s bit cch t chc nhcha gi

    tr ca bin.- a tn bin vo danh sch cc i tng c chng trnh qun l.- Trnh dch bit cch truy cp gi tr ca bin v p dng thao tc thch

    hp cho bin.3. integer, real, extended, longint.4. D5. C6. ))***1/(1/()/(*)1( xxxxazyxz +++ 7. a)

    b

    a2; b)

    2

    abc; c)

    ac

    b; d)

    ba

    b

    +2

    8. a)program bai8a;program bai8a;program bai8a;program bai8a;uses cruses cruses cruses crt;t;t;t;var x,y:real;var x,y:real;var x,y:real;var x,y:real;

    kt:boolean;kt:boolean;kt:boolean;kt:boolean;beginbeginbeginbeginclrscr;clrscr;clrscr;clrscr;

    write('Nhap x: ');readln(x);write('Nhap x: ');readln(x);write('Nhap x: ');readln(x);write('Nhap x: ');readln(x);write('Nhap y: ');readln(y);write('Nhap y: ');readln(y);write('Nhap y: ');readln(y);write('Nhap y: ');readln(y);kt:=false;kt:=false;kt:=false;kt:=false;if ((yabs(x)) or (y=abs(x)))if ((yabs(x)) or (y=abs(x)))if ((yabs(x)) or (y=abs(x)))if ((yabs(x)) or (y=abs(x)))thenthenthenthenkt:=true;kt:=true;kt:=true;kt:=true;

    if kt then write('Diem vua nhap thuoc phan gachif kt then write('Diem vua nhap thuoc phan gachif kt then write('Diem vua nhap thuoc phan gachif kt then write('Diem vua nhap thuoc phan gachcheo')cheo')cheo')cheo')

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    4/29

    Great by: Nguyn Trng Hong Email: [email protected]

    else write('Khong thuelse write('Khong thuelse write('Khong thuelse write('Khong thuoc');oc');oc');oc');readlnreadlnreadlnreadlnendendendend....

    V DV DV DV D

    b)program bai8;program bai8;program bai8;program bai8;uses crt;uses crt;uses crt;uses crt;var x,y:real;var x,y:real;var x,y:real;var x,y:real;kt:boolean;kt:boolean;kt:boolean;kt:boolean;

    beginbeginbeginbeginclrscr;clrscr;clrscr;clrscr;

    write('Nhap x: ');readln(x);write('Nhap x: ');readln(x);write('Nhap x: ');readln(x);write('Nhap x: ');readln(x);write('Nhap y: ');readln(y);write('Nhap y: ');readln(y);write('Nhap y: ');readln(y);write('Nhap y: ');readln(y);kt:=false;kt:=false;kt:=false;kt:=false;if (abs(y)

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    5/29

    Great by: Nguyn Trng Hong Email: [email protected]

    readlnreadlnreadlnreadlnendendendend....

    V DV DV DV D

    Bi 10.program bai10;program bai10;program bai10;program bai10;uses crt;uses crt;uses crt;uses crt;const g= 9.8;const g= 9.8;const g= 9.8;const g= 9.8;var v, h:real;var v, h:real;var v, h:real;var v, h:real;

    beginbeginbeginbeginclrscr;clrscr;clrscr;clrscr;repeatrepeatrepeatrepeat

    write('Nhap do cao: ');write('Nhap do cao: ');write('Nhap do cao: ');write('Nhap do cao: ');readln(h);readln(h);readln(h);readln(h);if h0;v:=sqrt(2*g*h);v:=sqrt(2*g*h);v:=sqrt(2*g*h);v:=sqrt(2*g*h);

    write('Van tocwrite('Van tocwrite('Van tocwrite('Van toc: ',v:8:3);: ',v:8:3);: ',v:8:3);: ',v:8:3);readlnreadlnreadlnreadln

    endendendend....V DV DV DV D

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    6/29

    Great by: Nguyn Trng Hong Email: [email protected]

    Chng 3Chng 3Chng 3Chng 3::::

    u trc r nhnh v lpu trc r nhnh v lpu trc r nhnh v lpu trc r nhnh v lp

    Bi Thc Hnh S 2Bi Thc Hnh S 2Bi Thc Hnh S 2Bi Thc Hnh S 2--------------------------------------------------------------------********************--------------------------------------------------------------------

    1. SGK2. Cu lnh ghp l mt cu lnh c hp thnh tnhiu cu lnh thnhphn. Cu lnh ghp nhm thc hin thao tc gm nhiu thao tc thnhphn. Mi thao tc thnh phn ng vi mt cu lnh n hoc mt cu lnhghp khc. Cu lnh ghp l mt trong cc yu t to kh nng chngtrnh c cu trc. Cc cu lnh t gia begin v end;Bi 3.Program tong1a;Program tong1a;Program tong1a;Program tong1a;Uses crt;Uses crt;Uses crt;Uses crt;Var S: real;Var S: real;Var S: real;Var S: real;

    a, N: integer;a, N: integer;a, N: integer;a, N: integer;beginbeginbeginbegin

    clrscr;clrscr;clrscr;clrscr;write('Nhap a: ');readln(a);write('Nhap a: ');readln(a);write('Nhap a: ');readln(a);write('Nhap a: ');readln(a);S:=1.0/a;S:=1.0/a;S:=1.0/a;S:=1.0/a;N:=1;N:=1;N:=1;N:=1;While n

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    7/29

    Great by: Nguyn Trng Hong Email: [email protected]

    Bi 4....

    a)a)a)a)programprogramprogramprogram bai4a;bai4a;bai4a;bai4a;uses crt;uses crt;uses crt;uses crt;var x, y, z:real;var x, y, z:real;var x, y, z:real;var x, y, z:real;beginbeginbeginbegin

    clrscr;clrscr;clrscr;clrscr;write('nhap hai so x va y: '); readln(x,y);write('nhap hai so x va y: '); readln(x,y);write('nhap hai so x va y: '); readln(x,y);write('nhap hai so x va y: '); readln(x,y);

    if x*x+y*y=x) thenif (x*x+y*y>1) and (y>=x) thenif (x*x+y*y>1) and (y>=x) thenbeginbeginbeginbeginz:=(x+y);z:=(x+y);z:=(x+y);z:=(x+y);

    writeln('tong can tim: ',z:9);writeln('tong can tim: ',z:9);writeln('tong can tim: ',z:9);writeln('tong can tim: ',z:9);endendendend;;;;if (x*x+y*y>1) and (y1) and (y1) and (y1) and (y

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    8/29

    Great by: Nguyn Trng Hong Email: [email protected]

    z:=abs(x)+abs(y);z:=abs(x)+abs(y);z:=abs(x)+abs(y);z:=abs(x)+abs(y);writeln('Z= ',z:3:3);writeln('Z= ',z:3:3);writeln('Z= ',z:3:3);writeln('Z= ',z:3:3);endendendend

    elseelseelseelsebbbbeginegineginegin

    z:=x+y;z:=x+y;z:=x+y;z:=x+y;writeln('Z= ',z:3:3);writeln('Z= ',z:3:3);writeln('Z= ',z:3:3);writeln('Z= ',z:3:3);

    endendendend;;;;readlnreadlnreadlnreadlnendendendend....

    V DV DV DV D

    Bi 5.a)a)a)a)ProgramProgramProgramProgram baibaibaibai5a;5a;5a;5a;Uses crt;Uses crt;Uses crt;Uses crt;Const n=50;Const n=50;Const n=50;Const n=50;Var i: integer;Var i: integer;Var i: integer;Var i: integer;

    Y:real;Y:real;Y:real;Y:real;BeginBeginBeginBegin

    Clrscr;Clrscr;Clrscr;Clrscr;for i:=1 to n dofor i:=1 to n dofor i:=1 to n dofor i:=1 to n doY:=i/(i+1);Y:=i/(i+1);Y:=i/(i+1);Y:=i/(i+1);Write('Tong Y: ',yWrite('Tong Y: ',yWrite('Tong Y: ',yWrite('Tong Y: ',y:9:3:9:3:9:3:9:3););););ReadlnReadlnReadlnReadln

    EndEndEndEnd....

    V DV DV DV D

    b)b)b)b)progrprogrprogrprogramamamam baibaibaibai5b;5b;5b;5b;uses crt;uses crt;uses crt;uses crt;varvarvarvar n:longint;n:longint;n:longint;n:longint;

    e,sh:real;e,sh:real;e,sh:real;e,sh:real;beginbeginbeginbeginclrscr;clrscr;clrscr;clrscr;

    sh:=1/2;sh:=1/2;sh:=1/2;sh:=1/2;n:=2;n:=2;n:=2;n:=2;

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    9/29

    Great by: Nguyn Trng Hong Email: [email protected]

    e:=2+sh;e:=2+sh;e:=2+sh;e:=2+sh;while sh>=2*1ewhile sh>=2*1ewhile sh>=2*1ewhile sh>=2*1e----16 do16 do16 do16 do

    beginbeginbeginbeginn:=n+1;n:=n+1;n:=n+1;n:=n+1;sh:=sh*(1/n);sh:=sh*(1/n);sh:=sh*(1/n);sh:=sh*(1/n);e:=e+sh;e:=e+sh;e:=e+sh;e:=e+sh;

    endendendend;;;;writeln('Gia tri e(n) la: ',e:10:6);writeln('Gia tri e(n) la: ',e:10:6);writeln('Gia tri e(n) la: ',e:10:6);writeln('Gia tri e(n) la: ',e:10:6);

    readlnreadlnreadlnreadlnendendendend....

    V DV DV DV D

    BiBiBiBi 6.6.6.6.prograprograprograprogrammmm Bai6Bai6Bai6Bai6;;;;uses crt;uses crt;uses crt;uses crt;var x, y:byte;var x, y:byte;var x, y:byte;var x, y:byte;beginbeginbeginbeginclrscr;clrscr;clrscr;clrscr;for x:=1 to 36 dofor x:=1 to 36 dofor x:=1 to 36 dofor x:=1 to 36 dofor y:=0 to 20 dofor y:=0 to 20 dofor y:=0 to 20 dofor y:=0 to 20 do

    if (x+y=36) and (2*x+4*y=100) thenif (x+y=36) and (2*x+4*y=100) thenif (x+y=36) and (2*x+4*y=100) thenif (x+y=36) and (2*x+4*y=100) thenbeginbeginbeginbegin

    writeln('Co ',x,' con Ga');writeln('Co ',x,' con Ga');writeln('Co ',x,' con Ga');writeln('Co ',x,' con Ga');write('Co ',y,' con Cho');write('Co ',y,' con Cho');write('Co ',y,' con Cho');write('Co ',y,' con Cho');endendendend;;;;readlnreadlnreadlnreadlnendendendend....

    V DV DV DV D

    Bi 7.programprogramprogramprogram Bai7Bai7Bai7Bai7;;;;uses crt;uses crt;uses crt;uses crt;var b, c, n:byte;var b, c, n:byte;var b, c, n:byte;var b, c, n:byte;begbegbegbegininininclrscr;clrscr;clrscr;clrscr;repeatrepeatrepeatrepeatwrite('Nhap tuoi cha: ');readln(b);write('Nhap tuoi cha: ');readln(b);write('Nhap tuoi cha: ');readln(b);write('Nhap tuoi cha: ');readln(b);

    write('Nhap tuoi con: ');readln(c);write('Nhap tuoi con: ');readln(c);write('Nhap tuoi con: ');readln(c);write('Nhap tuoi con: ');readln(c);if (bif (bif (bif (b----c

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    10/29

    Great by: Nguyn Trng Hong Email: [email protected]

    until (buntil (buntil (buntil (b----c>=25) and (b>=2*c);c>=25) and (b>=2*c);c>=25) and (b>=2*c);c>=25) and (b>=2*c);if b=2*c thenif b=2*c thenif b=2*c thenif b=2*c then

    writeln('Hien nay tuoi cha gap haiwriteln('Hien nay tuoi cha gap haiwriteln('Hien nay tuoi cha gap haiwriteln('Hien nay tuoi cha gap hai lan tuoi con.')lan tuoi con.')lan tuoi con.')lan tuoi con.')elseelseelseelseif b>2*c thenif b>2*c thenif b>2*c thenif b>2*c then

    writeln('Sau ',bwriteln('Sau ',bwriteln('Sau ',bwriteln('Sau ',b----2*c,' nam tuoi cha se gap doi tuoi2*c,' nam tuoi cha se gap doi tuoi2*c,' nam tuoi cha se gap doi tuoi2*c,' nam tuoi cha se gap doi tuoicon');con');con');con');readlnreadlnreadlnreadlnendendendend....

    V DV DV DV D

    Bi 8.programprogramprogramprogram Bai8Bai8Bai8Bai8;;;;uses crt;uses crt;uses crt;uses crt;var A, B, St, Luu :real;var A, B, St, Luu :real;var A, B, St, Luu :real;var A, B, St, Luu :real;

    n:byte;n:byte;n:byte;n:byte;beginbeginbeginbeginclrscr;clrscr;clrscr;clrscr;

    write('Nhap so tien gui: ');readln(a);write('Nhap so tien gui: ');readln(a);write('Nhap so tien gui: ');readln(a);write('Nhap so tien gui: ');readln(a);

    write(write(write(write('Nhap so tien nhan: ');readln(b);'Nhap so tien nhan: ');readln(b);'Nhap so tien nhan: ');readln(b);'Nhap so tien nhan: ');readln(b);luu:=A; n:=0; st:=a;luu:=A; n:=0; st:=a;luu:=A; n:=0; st:=a;luu:=A; n:=0; st:=a;while St

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    11/29

    Great by: Nguyn Trng Hong Email: [email protected]

    Chng 4Chng 4Chng 4Chng 4::::

    iu d liu c cu trciu d liu c cu trciu d liu c cu trciu d liu c cu trc

    Bi Thc Hnh S 3Bi Thc Hnh S 3Bi Thc Hnh S 3Bi Thc Hnh S 3--------------------------------------------------------------------********************--------------------------------------------------------------------

    Bi 1.program sum1;program sum1;program sum1;program sum1;uses crt;uses crt;uses crt;uses crt;const nmax=100;const nmax=100;const nmax=100;const nmax=100;type Myarray=array[1..nmax] of integer;type Myarray=array[1..nmax] of integer;type Myarray=array[1..nmax] of integer;type Myarray=array[1..nmax] of integer;var A:myarray;var A:myarray;var A:myarray;var A:myarray;

    s,n,i,k:integer;s,n,i,k:integer;s,n,i,k:integer;s,n,i,k:integer;posi,neg:integer;posi,neg:integer;posi,neg:integer;posi,neg:integer;

    beginbeginbeginbeginclrscr; randomize;clrscr; randomize;clrscr; randomize;clrscr; randomize;

    write('Nhap n: ');readln(n);write('Nhap n: ');readln(n);write('Nhap n: ');readln(n);write('Nhap n: ');readln(n);for i:=1 to n do Afor i:=1 to n do Afor i:=1 to n do Afor i:=1 to n do A[i]:=random(300)[i]:=random(300)[i]:=random(300)[i]:=random(300)----random(300);random(300);random(300);random(300);for i:=1 to n do write(A[i]:5); writeln;for i:=1 to n do write(A[i]:5); writeln;for i:=1 to n do write(A[i]:5); writeln;for i:=1 to n do write(A[i]:5); writeln;for i:=1 to n dofor i:=1 to n dofor i:=1 to n dofor i:=1 to n doif A[i]>0 then posi:=posi+1if A[i]>0 then posi:=posi+1if A[i]>0 then posi:=posi+1if A[i]>0 then posi:=posi+1else if A[i]

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    12/29

    Great by: Nguyn Trng Hong Email: [email protected]

    V DV DV DV D

    Bi ny cho kt qu ngu nhin nn kt qu ca cc bn c th khc.Bi 2.program mang2;program mang2;program mang2;program mang2;uses crt;uses crt;uses crt;uses crt;var A:array[1..100] of integer;var A:array[1..100] of integer;var A:array[1..100] of integer;var A:array[1..100] of integer;

    n,i,j,max:integer;n,i,j,max:integer;n,i,j,max:integer;n,i,j,max:integer;bebebebeginginginginclrscr;clrscr;clrscr;clrscr;

    write('Nhap so luong phan tu: ');readln(n);write('Nhap so luong phan tu: ');readln(n);write('Nhap so luong phan tu: ');readln(n);write('Nhap so luong phan tu: ');readln(n);for i:=1 to n dofor i:=1 to n dofor i:=1 to n dofor i:=1 to n dobeginbeginbeginbegin

    write('Nhap phan tu thu ',i,': '); readln(a[i]);write('Nhap phan tu thu ',i,': '); readln(a[i]);write('Nhap phan tu thu ',i,': '); readln(a[i]);write('Nhap phan tu thu ',i,': '); readln(a[i]);endendendend;;;;max:=a[1];max:=a[1];max:=a[1];max:=a[1];for i:=2 to n dofor i:=2 to n dofor i:=2 to n dofor i:=2 to n do

    if a[i]>a[iif a[i]>a[iif a[i]>a[iif a[i]>a[i----1] then max:=A[i];1] then max:=A[i];1] then max:=A[i];1] then max:=A[i];for j:=1 to n do if a[j]=max thenfor j:=1 to n do if a[j]=max thenfor j:=1 to n do if a[j]=max thenfor j:=1 to n do if a[j]=max then

    writeln('chi so phan tu lon nhwriteln('chi so phan tu lon nhwriteln('chi so phan tu lon nhwriteln('chi so phan tu lon nhat: ',j);at: ',j);at: ',j);at: ',j);readlnreadlnreadlnreadlnendendendend....

    V DV DV DV D

    Ch : Cc bn sa li chng trnh a ra kt qu hp l, cc ch s caphn tln nht cng nm trn mt dng.

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    13/29

    Great by: Nguyn Trng Hong Email: [email protected]

    Bi Thc Hnh S 4Bi Thc Hnh S 4Bi Thc Hnh S 4Bi Thc Hnh S 4

    --------------------------------------------------------------------********************--------------------------------------------------------------------Bi 1.uses crt;uses crt;uses crt;uses crt;var A:array[1..250] of integer;var A:array[1..250] of integer;var A:array[1..250] of integer;var A:array[1..250] of integer;

    n,i,j,y,demn,i,j,y,demn,i,j,y,demn,i,j,y,dem,t:integer;,t:integer;,t:integer;,t:integer;beginbeginbeginbeginclrscr;clrscr;clrscr;clrscr;randomize;randomize;randomize;randomize;

    write('Nhap n: ');readln(n);write('Nhap n: ');readln(n);write('Nhap n: ');readln(n);write('Nhap n: ');readln(n);for i:=1 to n do A[i]:=random(300)for i:=1 to n do A[i]:=random(300)for i:=1 to n do A[i]:=random(300)for i:=1 to n do A[i]:=random(300)----random(300);random(300);random(300);random(300);for i:=1 to n do write(A[i]:5);for i:=1 to n do write(A[i]:5);for i:=1 to n do write(A[i]:5);for i:=1 to n do write(A[i]:5);

    writeln;writeln;writeln;writeln;dem:=1;dem:=1;dem:=1;dem:=1;for j:=n downto 2 dofor j:=n downto 2 dofor j:=n downto 2 dofor j:=n downto 2 do

    for i:=1 to jfor i:=1 to jfor i:=1 to jfor i:=1 to j----1 do1 do1 do1 doif A[i]>A[i+1] thenif A[i]>A[i+1] thenif A[i]>A[i+1] thenif A[i]>A[i+1] thenbeginbeginbeginbegint:=a[i];t:=a[i];t:=a[i];t:=a[i];

    a[i]:=a[i+1];a[i]:=a[i+1];a[i]:=a[i+1];a[i]:=a[i+1];A[i+1]:=t;A[i+1]:=t;A[i+1]:=t;A[i+1]:=t;dem:=dem+1;dem:=dem+1;dem:=dem+1;dem:=dem+1;

    endendendend;;;;write('Sau khi dao ',dem,' lan');write('Sau khi dao ',dem,' lan');write('Sau khi dao ',dem,' lan');write('Sau khi dao ',dem,' lan');for i:=1 to n dofor i:=1 to n dofor i:=1 to n dofor i:=1 to n do

    write(A[i]:7);write(A[i]:7);write(A[i]:7);write(A[i]:7);writeln;writeln;writeln;writeln;readlnreadlnreadlnreadln

    endendendend....V DV DV DV D

    Bi ny cho kt qu l ngu nhin.

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    14/29

    Great by: Nguyn Trng Hong Email: [email protected]

    Bi Thc Hnh S 5Bi Thc Hnh S 5Bi Thc Hnh S 5Bi Thc Hnh S 5

    --------------------------------------------------------------------********************--------------------------------------------------------------------Bi 1.program xau;program xau;program xau;program xau;uses crt;uses crt;uses crt;uses crt;var i, x:byte;var i, x:byte;var i, x:byte;var i, x:byte;

    S: string;S: string;S: string;S: string;kt:boolean;kt:boolean;kt:boolean;kt:boolean;

    beginbeginbeginbeginclrscr;clrscr;clrscr;clrscr;

    write('Nhap xau:write('Nhap xau:write('Nhap xau:write('Nhap xau: ');readln(s);');readln(s);');readln(s);');readln(s);x:=length(S);x:=length(S);x:=length(S);x:=length(S);kt:=true;kt:=true;kt:=true;kt:=true;for i:=1 to x div 2 dofor i:=1 to x div 2 dofor i:=1 to x div 2 dofor i:=1 to x div 2 do

    if S[i]S[xif S[i]S[xif S[i]S[xif S[i]S[x----i+1] then kt:=false;i+1] then kt:=false;i+1] then kt:=false;i+1] then kt:=false;if kt then write('Xau la palindrome')if kt then write('Xau la palindrome')if kt then write('Xau la palindrome')if kt then write('Xau la palindrome')else write('Xau khong la palindrome');else write('Xau khong la palindrome');else write('Xau khong la palindrome');else write('Xau khong la palindrome');readlnreadlnreadlnreadln

    endendendend....

    V DV DV DV D

    Bi 2.program Bai2;program Bai2;program Bai2;program Bai2;uses crt;uses crt;uses crt;uses crt;var S:string;var S:string;var S:string;var S:string;

    i,n,dem:inti,n,dem:inti,n,dem:inti,n,dem:integer;eger;eger;eger;ch:char;ch:char;ch:char;ch:char;beginbeginbeginbeginclrscr;clrscr;clrscr;clrscr;

    write('Nhap xau: ');readln(S);write('Nhap xau: ');readln(S);write('Nhap xau: ');readln(S);write('Nhap xau: ');readln(S);for i:=1 to length(S) dofor i:=1 to length(S) dofor i:=1 to length(S) dofor i:=1 to length(S) dos[i]:=upcase(s[i]);s[i]:=upcase(s[i]);s[i]:=upcase(s[i]);s[i]:=upcase(s[i]);for ch:='A' to 'Z' dofor ch:='A' to 'Z' dofor ch:='A' to 'Z' dofor ch:='A' to 'Z' dobeginbeginbeginbegindem:=0;dem:=0;dem:=0;dem:=0;

    for i:=1 to length(s) dofor i:=1 to length(s) dofor i:=1 to length(s) dofor i:=1 to length(s) doif s[i]=ch then dem:=dem+1;if s[i]=ch then dem:=dem+1;if s[i]=ch then dem:=dem+1;if s[i]=ch then dem:=dem+1;

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    15/29

    Great by: Nguyn Trng Hong Email: [email protected]

    if dem>0 thenif dem>0 thenif dem>0 thenif dem>0 thenwriteln('Trong xau co ',dem,' chu ',ch);writeln('Trong xau co ',dem,' chu ',ch);writeln('Trong xau co ',dem,' chu ',ch);writeln('Trong xau co ',dem,' chu ',ch);endendendend;;;;readlnreadlnreadlnreadlnendendendend....

    V DV DV DV D

    Bi 3.program anhem;program anhem;program anhem;program anhem;

    uses crt;uses crt;uses crt;uses crt;var S:string;var S:string;var S:string;var S:string;

    i,n:integer;i,n:integer;i,n:integer;i,n:integer;beginbeginbeginbeginclrscr;clrscr;clrscr;clrscr;

    write('Nhap xau: ');readln(s);write('Nhap xau: ');readln(s);write('Nhap xau: ');readln(s);write('Nhap xau: ');readln(s);while pos('anh',s) 0 dowhile pos('anh',s) 0 dowhile pos('anh',s) 0 dowhile pos('anh',s) 0 dobeginbeginbeginbeginn:=pos('anh',s);n:=pos('anh',s);n:=pos('anh',s);n:=pos('anh',s);

    delete(S,n,3);delete(S,n,3);delete(S,n,3);delete(S,n,3);insert('em',s,n);insert('em',s,n);insert('em',s,n);insert('em',s,n);ENDENDENDEND;;;;

    write('Xau moi: ',s);write('Xau moi: ',s);write('Xau moi: ',s);write('Xau moi: ',s);readlnreadlnreadlnreadlnendendendend....

    V DV DV DV D

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    16/29

    Great by: Nguyn Trng Hong Email: [email protected]

    Bi tp chng 4Bi tp chng 4Bi tp chng 4Bi tp chng 41.Mng l kiu dliu c cu trc bi v mng l kiu c cu trc c

    cp ti sm nht trong cc ngn ng lp trnh. N c xy dngtnhng kiu dliu c theo quy tc khun dng do ngn nglptrnh cung cp. N c dng chnh mt nhm i tng cngmt tnh cht no .

    2.Chng ta phi khai bo kch thc mng bi v cch nh s ccphn tca n.

    3.real, boolean, integer, longint.4.Tham chiu n phn t ca mng mt chiu c xc nh bi tnmng cng vi ch s, c vit trong cp ngoc [..] (V d A[1]). Cntham chiu n phn tca mng 2 chiu c xc nh bi tn mngcng vi 2 ch sc phn cch bi du phy v vit trong cp ngoc[..] (A[1,2]).

    Bi 5.uses crt;uses crt;uses crt;uses crt;var a:array[1..100] of integer;var a:array[1..100] of integer;var a:array[1..100] of integer;var a:array[1..100] of integer;

    n,i,d:integer;n,i,d:integer;n,i,d:integer;n,i,d:integer;ccccsc:boolean;sc:boolean;sc:boolean;sc:boolean;

    beginbeginbeginbeginclrscr;clrscr;clrscr;clrscr;

    write('Nhap n: ');readln(n);write('Nhap n: ');readln(n);write('Nhap n: ');readln(n);write('Nhap n: ');readln(n);for i:=1 to n dofor i:=1 to n dofor i:=1 to n dofor i:=1 to n dobeginbeginbeginbeginrepeatrepeatrepeatrepeat

    write('Nhap phan tu thu ',i,': ');write('Nhap phan tu thu ',i,': ');write('Nhap phan tu thu ',i,': ');write('Nhap phan tu thu ',i,': ');

    readln(a[i]);readln(a[i]);readln(a[i]);readln(a[i]);if abs(a[i])>1000 then writeln('Nhap so nho honif abs(a[i])>1000 then writeln('Nhap so nho honif abs(a[i])>1000 then writeln('Nhap so nho honif abs(a[i])>1000 then writeln('Nhap so nho hon1000');1000');1000');1000');until abs(a[i])

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    17/29

    Great by: Nguyn Trng Hong Email: [email protected]

    Bai 6.Bai 6.Bai 6.Bai 6.program bai6;program bai6;program bai6;program bai6;uses crt;uses crt;uses crt;uses crt;var A:array[1..100] of integer;var A:array[1..100] of integer;var A:array[1..100] of integer;var A:array[1..100] of integer;

    i,n,dem,u,d:integer;i,n,dem,u,d:integer;i,n,dem,u,d:integer;i,n,dem,u,d:integer;beginbeginbeginbeginclrscr;clrscr;clrscr;clrscr;

    write('Nhap sowrite('Nhap sowrite('Nhap sowrite('Nhap so luong phan tu: ');readln(n);luong phan tu: ');readln(n);luong phan tu: ');readln(n);luong phan tu: ');readln(n);for i:=1 to n dofor i:=1 to n dofor i:=1 to n dofor i:=1 to n dobeginbeginbeginbeginrepeatrepeatrepeatrepeat

    write('Nhap phan tu thu ',i,': ');write('Nhap phan tu thu ',i,': ');write('Nhap phan tu thu ',i,': ');write('Nhap phan tu thu ',i,': ');

    readln(a[i]);readln(a[i]);readln(a[i]);readln(a[i]);if abs(A[i])>1000 then write('Nhap so

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    18/29

    Great by: Nguyn Trng Hong Email: [email protected]

    readlnreadlnreadlnreadlnendendendend....

    V DV DV DV D

    Bi 7.program bai7;program bai7;program bai7;program bai7;uses crt;uses crt;uses crt;uses crt;var n, i:word;var n, i:word;var n, i:word;var n, i:word; f, f1,f2:word;f, f1,f2:word;f, f1,f2:word;f, f1,f2:word;beginbeginbeginbeginclrscr;clrscr;clrscr;clrscr;repeatrepeatrepeatrepeat

    write('Nhap N: ');readln(n);write('Nhap N: ');readln(n);write('Nhap N: ');readln(n);write('Nhap N: ');readln(n);if n=2;until n>=2;until n>=2;until n>=2;f1:=1;f1:=1;f1:=1;f1:=1;f2:=2;f2:=2;f2:=2;f2:=2;for i:=3 to n dofor i:=3 to n dofor i:=3 to n dofor i:=3 to n dobeginbeginbeginbeginf:=f1+f2;f:=f1+f2;f:=f1+f2;f:=f1+f2;f1:=f2;f1:=f2;f1:=f2;f1:=f2;f2:=f;f2:=f;f2:=f;f2:=f;endendendend;;;;

    write('So fibonaxi thuwrite('So fibonaxi thuwrite('So fibonaxi thuwrite('So fibonaxi thu ',n,' la ' ,f);',n,' la ' ,f);',n,' la ' ,f);',n,' la ' ,f);readlnreadlnreadlnreadlnendendendend....

    V DV DV DV D

    Chng trnh thc hin nChng trnh thc hin nChng trnh thc hin nChng trnh thc hin nNmax=10001.Nmax=10001.Nmax=10001.Nmax=10001.Bi 8.Bi 8.Bi 8.Bi 8.

    Chng trnh thc hin vic hon i v tr dng th i vi dng thN-i+1,ngha l hon i v tr dng u tin vi dng cui cng ca mng hai

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    19/29

    Great by: Nguyn Trng Hong Email: [email protected]

    chiu, dng thhai ttrn xung vi dng thhai tdi ln, Vic honi v tr dng thi vi dng i xng vi n c thc hin khi i nhn gi

    tr t1 n N, lm cho mi dng c hon i v tr 2 ln. V vy mng Asau khi hon i khng thay i so vi ban u.Bi 9.program bai9;program bai9;program bai9;program bai9;uses crt;uses crt;uses crt;uses crt;var A:array[1..15,1..15] of integer;var A:array[1..15,1..15] of integer;var A:array[1..15,1..15] of integer;var A:array[1..15,1..15] of integer;

    N, i, j, max, ind,N, i, j, max, ind,N, i, j, max, ind,N, i, j, max, ind, vsp:integer;vsp:integer;vsp:integer;vsp:integer;beginbeginbeginbeginclrscr;clrscr;clrscr;clrscr;

    write('Nhap N: ');readln(n);write('Nhap N: ');readln(n);write('Nhap N: ');readln(n);write('Nhap N: ');readln(n);for i:=1 to n dofor i:=1 to n dofor i:=1 to n dofor i:=1 to n do

    for j:=1 to n dofor j:=1 to n dofor j:=1 to n dofor j:=1 to n dobeginbeginbeginbegin

    write('Nhap A[',i,',',j,']: ');write('Nhap A[',i,',',j,']: ');write('Nhap A[',i,',',j,']: ');write('Nhap A[',i,',',j,']: ');readln(A[i,j]);readln(A[i,j]);readln(A[i,j]);readln(A[i,j]);

    endendendend;;;;for i:=1 to n dofor i:=1 to n dofor i:=1 to n dofor i:=1 to n do

    beginbeginbeginbeginmax:=A[1,i];ind:=1;max:=A[1,i];ind:=1;max:=A[1,i];ind:=1;max:=A[1,i];ind:=1;for j:=2 to n dofor j:=2 to n dofor j:=2 to n dofor j:=2 to n doif A[j,i] > max thenif A[j,i] > max thenif A[j,i] > max thenif A[j,i] > max then

    beginbeginbeginbeginmax:=A[j,i];max:=A[j,i];max:=A[j,i];max:=A[j,i];ind:=j;ind:=j;ind:=j;ind:=j;endendendend;;;;

    vsp:=A[i,i];vsp:=A[i,i];vsp:=A[i,i];vsp:=A[i,i];A[i,i]:=max;A[i,i]:=max;A[i,i]:=max;A[i,i]:=max;A[ind,i]:=vsp;A[ind,i]:=vsp;A[ind,i]:=vsp;A[ind,i]:=vsp;

    endendendend;;;;for i:=1 to n dofor i:=1 to n dofor i:=1 to n dofor i:=1 to n do

    beginbeginbeginbeginwriteln;writeln;writeln;writeln;for j:=1 to n do write(A[i,j]:3);for j:=1 to n do write(A[i,j]:3);for j:=1 to n do write(A[i,j]:3);for j:=1 to n do write(A[i,j]:3);

    endendendend;;;;writeln;writeln;writeln;writeln;readlnreadlnreadlnreadln

    endendendend....

    V DV DV DV D

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    20/29

    Great by: Nguyn Trng Hong Email: [email protected]

    Bi 10.program bai10;program bai10;program bai10;program bai10;uses crt;uses crt;uses crt;uses crt;var S:string;var S:string;var S:string;var S:string;

    i,dem,n:integer;i,dem,n:integer;i,dem,n:integer;i,dem,n:integer;beginbeginbeginbeginclrscr;clrscr;clrscr;clrscr;

    write('Nhap xau: ');readln(S);write('Nhap xau: ');readln(S);write('Nhap xau: ');readln(S);write('Nhap xau: ');readln(S);n:=length(S);n:=length(S);n:=length(S);n:=length(S);dem:=0;dem:=0;dem:=0;dem:=0;for i:=1 to n dofor i:=1 to n dofor i:=1 to n dofor i:=1 to n doif (s[i]>='0') and (s[i]='0') and (s[i]='0') and (s[i]='0') and (s[i]

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    21/29

    Great by: Nguyn Trng Hong Email: [email protected]

    for i:=1 to nfor i:=1 to nfor i:=1 to nfor i:=1 to n dodododowith lop[i] dowith lop[i] dowith lop[i] dowith lop[i] do {Ch cu lnh ny}{Ch cu lnh ny}{Ch cu lnh ny}{Ch cu lnh ny}beginbeginbeginbegin

    writeln('Nhap so lieu hoc sinh thu ',i,':');writeln('Nhap so lieu hoc sinh thu ',i,':');writeln('Nhap so lieu hoc sinh thu ',i,':');writeln('Nhap so lieu hoc sinh thu ',i,':');write('Ho va ten: ');readln(hoten);write('Ho va ten: ');readln(hoten);write('Ho va ten: ');readln(hoten);write('Ho va ten: ');readln(hoten);write('Ngay sinh: ');readln(ngaysinh);write('Ngay sinh: ');readln(ngaysinh);write('Ngay sinh: ');readln(ngaysinh);write('Ngay sinh: ');readln(ngaysinh); write('Dia chi : ');readln(diachi); write('Dia chi : ');readln(diachi); write('Dia chi : ');readln(diachi); write('Dia chi : ');readln(diachi);write('Diem toan: ');readln(toan);write('Diem toan: ');readln(toan);write('Diem toan: ');readln(toan);write('Diem toan: ');readln(toan);write('Diem van : 'write('Diem van : 'write('Diem van : 'write('Diem van : ');readln(van););readln(van););readln(van););readln(van);if toan+van>=18 then xeploai:='A';if toan+van>=18 then xeploai:='A';if toan+van>=18 then xeploai:='A';if toan+van>=18 then xeploai:='A';if (toan+van>=14) and (toan+van=14) and (toan+van=14) and (toan+van=14) and (toan+van=10) and (toan+van=10) and (toan+van=10) and (toan+van=10) and (toan+van

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    22/29

    Great by: Nguyn Trng Hong Email: [email protected]

    Kt quKt quKt quKt qu

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    23/29

    Great by: Nguyn Trng Hong Email: [email protected]

    Chng 5Chng 5Chng 5Chng 5::::

    hao tc vihao tc vihao tc vihao tc vi tptptptp

    Bi tp chngBi tp chngBi tp chngBi tp chng

    1.Mt strng hp phi dng tp: lu tr lng thng tin ln, dnglu di, t thay i nh tn ngi trong mt cquan, h s ca sinhvin, lng cn b,....

    2.SGK3.Phi m tp trc khi c tp v trc khi sdng tp phi c culnh mtp trnh dch bit thc hin mc ch m tp c hayghi, ng thi t con tr tp vo v tr thch hp

    4.Phi dng lnh ng tp sau hi kt thc ghi dliu vo tp thngtt vic ghi dliu ra tp. Khng c cu lnh ng tp th chng trnhs khng th ghi c dliu vo tp.

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    24/29

    Great by: Nguyn Trng Hong Email: [email protected]

    Chng 6Chng 6Chng 6Chng 6::::hng trnh con v lp trnh chng trnh con v lp trnh chng trnh con v lp trnh chng trnh con v lp trnh c

    cu trccu trccu trccu trc

    Bi Thc Hnh S 6Bi Thc Hnh S 6Bi Thc Hnh S 6Bi Thc Hnh S 6--------------------------------------------------------------------********************--------------------------------------------------------------------

    Chng trnhprogramprogramprogramprogram thuchanh6thuchanh6thuchanh6thuchanh6;;;;uses crt;uses crt;uses crt;uses crt;type str = string[79];type str = string[79];type str = string[79];type str = string[79];var S1, S2:str;var S1, S2:str;var S1, S2:str;var S1, S2:str;

    dodododong:byte;ng:byte;ng:byte;ng:byte;dung:boolean;dung:boolean;dung:boolean;dung:boolean;

    procedure catdan(s1:str; var s2: str);procedure catdan(s1:str; var s2: str);procedure catdan(s1:str; var s2: str);procedure catdan(s1:str; var s2: str);beginbeginbeginbegins2:=copy(s1,2,length(s1)s2:=copy(s1,2,length(s1)s2:=copy(s1,2,length(s1)s2:=copy(s1,2,length(s1)----1)+S1[1];1)+S1[1];1)+S1[1];1)+S1[1];end;end;end;end;procedure cangiua(var s:str);procedure cangiua(var s:str);procedure cangiua(var s:str);procedure cangiua(var s:str);

    var n, i:integer;var n, i:integer;var n, i:integer;var n, i:integer;beginbeginbeginbeginn:=length(s);n:=length(s);n:=length(s);n:=length(s);n:=(80n:=(80n:=(80n:=(80----n) div 2;n) div 2;n) div 2;n) div 2;for i:=1 to n do s:=' '+s;for i:=1 to n do s:=' '+s;for i:=1 to n do s:=' '+s;for i:=1 to n do s:=' '+s;end;end;end;end;procedure chuchay(s1:str; dongprocedure chuchay(s1:str; dongprocedure chuchay(s1:str; dongprocedure chuchay(s1:str; dong:byte);:byte);:byte);:byte);var s2:str;var s2:str;var s2:str;var s2:str;

    dung:boolean;dung:boolean;dung:boolean;dung:boolean;

    beginbeginbeginbeginclrscr;clrscr;clrscr;clrscr;cangiua(s1);cangiua(s1);cangiua(s1);cangiua(s1);clrscr;clrscr;clrscr;clrscr;dung:=false;dung:=false;dung:=false;dung:=false;

    while not(dung) dowhile not(dung) dowhile not(dung) dowhile not(dung) dobeginbeginbeginbegingotoxy(1,dong);gotoxy(1,dong);gotoxy(1,dong);gotoxy(1,dong);

    write(s1);write(s1);write(s1);write(s1);delay(100);delay(100);delay(100);delay(100);catdan(s1,s2);catdan(s1,s2);catdan(s1,s2);catdan(s1,s2);s1:=s2;s1:=s2;s1:=s2;s1:=s2;24

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    25/29

    Great by: Nguyn Trng Hong Email: [email protected]

    dung:=keypressed;dung:=keypressed;dung:=keypressed;dung:=keypressed;end;end;end;end;end;end;end;end;beginbeginbeginbeginclrscr;clrscr;clrscr;clrscr;

    write('Nhap xau : ');readln(s1);write('Nhap xau : ');readln(s1);write('Nhap xau : ');readln(s1);write('Nhap xau : ');readln(s1);write('Nhawrite('Nhawrite('Nhawrite('Nhap dong: ');readln(dong);p dong: ');readln(dong);p dong: ');readln(dong);p dong: ');readln(dong);chuchay(s1,dong);chuchay(s1,dong);chuchay(s1,dong);chuchay(s1,dong);readlnreadlnreadlnreadlnend.end.end.end.

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    26/29

    Great by: Nguyn Trng Hong Email: [email protected]

    Bi Thc Hnh S 7Bi Thc Hnh S 7Bi Thc Hnh S 7Bi Thc Hnh S 7--------------------------------------------------------------------********************--------------------------------------------------------------------

    program ttamgiac;program ttamgiac;program ttamgiac;program ttamgiac;uses crt;uses crt;uses crt;uses crt;const eps=1.0econst eps=1.0econst eps=1.0econst eps=1.0e----6;6;6;6;typetypetypetype

    diem=recorddiem=recorddiem=recorddiem=recordx, y:real;x, y:real;x, y:real;x, y:real;end;end;end;end;

    tamgiac=recordtamgiac=recordtamgiac=recordtamgiac=record

    a, b, c:diem;a, b, c:diem;a, b, c:diem;a, b, c:diem;end;end;end;end;

    var T:tamgiac;var T:tamgiac;var T:tamgiac;var T:tamgiac;d, cn, v: boolean;d, cn, v: boolean;d, cn, v: boolean;d, cn, v: boolean;n, i, deu, can, vuong:word;n, i, deu, can, vuong:word;n, i, deu, can, vuong:word;n, i, deu, can, vuong:word;f,g:text;f,g:text;f,g:text;f,g:text;

    function khcach(P, Q: Diem):real;function khcach(P, Q: Diem):real;function khcach(P, Q: Diem):real;function khcach(P, Q: Diem):real;beginbeginbeginbeginkhcach:=sqrt((P.xkhcach:=sqrt((P.xkhcach:=sqrt((P.xkhcach:=sqrt((P.x----Q.x)*(p.xQ.x)*(p.xQ.x)*(p.xQ.x)*(p.x----q.x)+(p.yq.x)+(p.yq.x)+(p.yq.x)+(p.y----Q.y)*(p.yQ.y)*(p.yQ.y)*(p.yQ.y)*(p.y----Q.y));Q.y));Q.y));Q.y));

    end;end;end;end;procedure daicanh(var R:tamgiac; var a, b, c:real);procedure daicanh(var R:tamgiac; var a, b, c:real);procedure daicanh(var R:tamgiac; var a, b, c:real);procedure daicanh(var R:tamgiac; var a, b, c:real);bbbbeginegineginegina:=khcach(R.B, R.C);a:=khcach(R.B, R.C);a:=khcach(R.B, R.C);a:=khcach(R.B, R.C);b:=khcach(R.A, R.C);b:=khcach(R.A, R.C);b:=khcach(R.A, R.C);b:=khcach(R.A, R.C);c:=khcach(R.A, R.B);c:=khcach(R.A, R.B);c:=khcach(R.A, R.B);c:=khcach(R.A, R.B);end;end;end;end;procedure tinhchat(var R: tamgiac; varprocedure tinhchat(var R: tamgiac; varprocedure tinhchat(var R: tamgiac; varprocedure tinhchat(var R: tamgiac; vardeu,can,vuong:boolean);deu,can,vuong:boolean);deu,can,vuong:boolean);deu,can,vuong:boolean);

    var a, b, c:real;var a, b, c:real;var a, b, c:real;var a, b, c:real;beginbeginbeginbegindeu:=false; can:=false; vuong:=false;deu:=false; can:=false; vuong:=false;deu:=false; can:=false; vuong:=false;deu:=false; can:=false; vuong:=false;daicanh(R,a,b,c);daicanh(R,a,b,c);daicanh(R,a,b,c);daicanh(R,a,b,c);if (abs(aif (abs(aif (abs(aif (abs(a----b)

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    27/29

    Great by: Nguyn Trng Hong Email: [email protected]

    vuong:=true;vuong:=true;vuong:=true;vuong:=true;end;end;end;end;beginbeginbeginbegindeu:=0;deu:=0;deu:=0;deu:=0;can:=0;can:=0;can:=0;can:=0;vuong:=0;vuong:=0;vuong:=0;vuong:=0;assign(f,'tamgiac.dat');assign(f,'tamgiac.dat');assign(f,'tamgiac.dat');assign(f,'tamgiac.dat');reset(f);reset(f);reset(f);reset(f);rrrreadln(f,n);eadln(f,n);eadln(f,n);eadln(f,n);assign(g,'tamgiac.out');assign(g,'tamgiac.out');assign(g,'tamgiac.out');assign(g,'tamgiac.out');rewrite(g);rewrite(g);rewrite(g);rewrite(g);for i:=1 to n dofor i:=1 to n dofor i:=1 to n dofor i:=1 to n do

    beginbeginbeginbeginreadln(f, T.A.x, T.A.y, T.B.x, T.B.y, T.C.x, T.C.y);readln(f, T.A.x, T.A.y, T.B.x, T.B.y, T.C.x, T.C.y);readln(f, T.A.x, T.A.y, T.B.x, T.B.y, T.C.x, T.C.y);readln(f, T.A.x, T.A.y, T.B.x, T.B.y, T.C.x, T.C.y);tinhchat(T,D,cn,v);tinhchat(T,D,cn,v);tinhchat(T,D,cn,v);tinhchat(T,D,cn,v);if d then deu:=deu+1 elseif d then deu:=deu+1 elseif d then deu:=deu+1 elseif d then deu:=deu+1 elsebeginbeginbeginbeginif cn then can:=can+1;if cn then can:=can+1;if cn then can:=can+1;if cn then can:=can+1;if v then vuong:=vuong+1;if v then vuong:=vuong+1;if v then vuong:=vuong+1;if v then vuong:=vuong+1;end;end;end;end;end;end;end;end;

    writeln(g,'co ',deu,writeln(g,'co ',deu,writeln(g,'co ',deu,writeln(g,'co ',deu,' tam giac deu');' tam giac deu');' tam giac deu');' tam giac deu');writeln(g,'co ',can,' tam giac can');writeln(g,'co ',can,' tam giac can');writeln(g,'co ',can,' tam giac can');writeln(g,'co ',can,' tam giac can');writeln(g,'co ',vuong,' tam giac vuong');writeln(g,'co ',vuong,' tam giac vuong');writeln(g,'co ',vuong,' tam giac vuong');writeln(g,'co ',vuong,' tam giac vuong');close(f);close(g);close(f);close(g);close(f);close(g);close(f);close(g);end.end.end.end.

    V DV DV DV DTp vn bn cha ta cc nh ca cc tam gicTp vn bn cha ta cc nh ca cc tam gicTp vn bn cha ta cc nh ca cc tam gicTp vn bn cha ta cc nh ca cc tam gicVoVoVoVofilefilefilefile----openopenopenopen----gggg tamgiac.dattamgiac.dattamgiac.dattamgiac.dat----nhy ntnhy ntnhy ntnhy nt openopenopenopen ri nhp d liuri nhp d liuri nhp d liuri nhp d liu

    nh dinh dinh dinh di, nhn, nhn, nhn, nhn f2f2f2f2 lu li lu li lu li lu li

    VoVoVoVofilefilefilefile----openopenopenopen----g tamgiac.outg tamgiac.outg tamgiac.outg tamgiac.out----nhy nt opennhy nt opennhy nt opennhy nt open ri nhnri nhnri nhnri nhn f2f2f2f2 lululululilili li. Nhn. Nhn. Nhn. Nhn f6f6f6f6 chuyn sang ca s chng trnh v chy chng trnh. Chy xongchuyn sang ca s chng trnh v chy chng trnh. Chy xongchuyn sang ca s chng trnh v chy chng trnh. Chy xongchuyn sang ca s chng trnh v chy chng trnh. Chy xongnhnnhnnhnnhnyesyesyesyes, nhn, nhn, nhn, nhn f6f6f6f6 cho n khi xut hin ca s vn bncho n khi xut hin ca s vn bncho n khi xut hin ca s vn bncho n khi xut hin ca s vn bn tamgiac.outtamgiac.outtamgiac.outtamgiac.out xemxemxemxemkt qu.kt qu.kt qu.kt qu.Tp vn bn chaTp vn bn chaTp vn bn chaTp vn bn cha kt qu sau khi thc hin chng trnhkt qu sau khi thc hin chng trnhkt qu sau khi thc hin chng trnhkt qu sau khi thc hin chng trnh

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    28/29

    Great by: Nguyn Trng Hong Email: [email protected]

    Bi tp chngBi tp chngBi tp chngBi tp chng

    1.SGK2.Chng trnh con khng c tham sProcedure ve;Procedure ve;Procedure ve;Procedure ve;

    BeginBeginBeginBeginWriteln(****************);Writeln(****************);Writeln(****************);Writeln(****************);Writeln(*I love you ok!*);Writeln(*I love you ok!*);Writeln(*I love you ok!*);Writeln(*I love you ok!*);Writeln(****************);Writeln(****************);Writeln(****************);Writeln(****************);End;End;End;End;

    3.Chng trnh con cho nhiu hn mt kt qu:Procedure hoandoi(var x, y:integer);Procedure hoandoi(var x, y:integer);Procedure hoandoi(var x, y:integer);Procedure hoandoi(var x, y:integer);Var tg:integer;Var tg:integer;Var tg:integer;Var tg:integer;BeginBeginBeginBegin

    Tg:=x;Tg:=x;Tg:=x;Tg:=x;X:=y;X:=y;X:=y;X:=y;Y:=tg;Y:=tg;Y:=tg;Y:=tg;End;End;End;End;

    4.program bai4;program bai4;program bai4;program bai4;uses crt;uses crt;uses crt;uses crt;var x, y:integer;var x, y:integer;var x, y:integer;var x, y:integer;function ucln(a, b:integer): integer;function ucln(a, b:integer): integer;function ucln(a, b:integer): integer;function ucln(a, b:integer): integer;

    var r:integer;var r:integer;var r:integer;var r:integer;beginbeginbeginbeginwhile b>0 dowhile b>0 dowhile b>0 dowhile b>0 dobeginbeginbeginbeginr:=a mod b;r:=a mod b;r:=a mod b;r:=a mod b;a:=b;a:=b;a:=b;a:=b;b:=r;b:=r;b:=r;b:=r;end;end;end;end;ucln:=a;ucln:=a;ucln:=a;ucln:=a;end;end;end;end;function bcnn(a, b:integer): integer;function bcnn(a, b:integer): integer;function bcnn(a, b:integer): integer;function bcnn(a, b:integer): integer;beginbeginbeginbegin

  • 8/14/2019 Giai_bai_tap_tin_hoc_11_6075_10443540

    29/29

    Great by: Nguyn Trng Hong Email: [email protected]

    bcnn:=a*b div ucln(a,b);bcnn:=a*b div ucln(a,b);bcnn:=a*b div ucln(a,b);bcnn:=a*b div ucln(a,b);enenenend;d;d;d;beginbeginbeginbeginclrscr;clrscr;clrscr;clrscr;

    write('Nhap x: ');readln(x);write('Nhap x: ');readln(x);write('Nhap x: ');readln(x);write('Nhap x: ');readln(x);write('Nhap y: ');readln(y);write('Nhap y: ');readln(y);write('Nhap y: ');readln(y);write('Nhap y: ');readln(y);write('Boi chung nho nhat: ',bcnn(x,y));write('Boi chung nho nhat: ',bcnn(x,y));write('Boi chung nho nhat: ',bcnn(x,y));write('Boi chung nho nhat: ',bcnn(x,y));readlnreadlnreadlnreadlnend.end.end.end.

    V DV DV DV D