KiÕn thøc chung vÒ tin häc vµ m¸y tÝnh ®iÖn tö I kh¸i niÖm vÒ Th«ng tin : ( InFORMATION ) + Mçi ®èi tîng trong mét vÊn ®Ò nghiªn cøu , chøa mét tËp c¸c ®Æc trng cña nã . §èi tîng häc sinh trong bµi to¸n qu¶n lý ®iÓm gåm c¸c ®Æc trng : sè b¸o danh, hä tªn, ngµy sinh, ®iÓm c¸c m«n ...TËp c¸c gi¸ trÞ cña c¸c ®Æc trng nµy gäi lµ tËp c¸c d÷ liÖu m« t¶ ®èi tîng . + Th«ng tin vÒ mét ®èi tîng : lµ mét d¹ng vËt chÊt gióp chóng ta nhËn biÕt vµ hiÓu râ h¬n vÒ ®èi tîng nghÜa lµ nhê th«ng tin nµy ta hiÓu râ h¬n c¸c ®Æc trng cña ®èi tîng . + §é bÊt ®Þnh cña ®èi tîng : Gi¶ sö hiÖn t¹i mét ®èi tîng cã n tr¹ng th¸i , nÕu kh¶ n¨ng xuÊt hiÖn tr¹ng th¸i i (1i then i := j; End; Cau2(n,p,i); End; End; BEGIN Clrscr; Assign(f,Inp); Reset(f); Lam; Close(f); Readln; END Bài 12 : {$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q-,R+,S+,T-,V+,X+} {$M 16384,0,655360} Uses crt; Const Max = 1000; Fsnt = 'SNT.txt'; Type Ta = Array[1 max] of Longint; Var P,Q,E,D,N,W : Longint; fi,fo,fin : String; F,fr,findex : Text; sosont : Integer; A : Ta; Ch : Char; Procedure MOFILEDOC; Var ok : Boolean; Begin Writeln; Repeat Write('File name data input : '); Readln(fi); Assign(f,fi); {$i-} Reset(f); {$i+} Ok:=(Ioresult=0); If Not Ok Then Write('Error file data ',fi,' Enter to quit'); Until Ok; End; Procedure Mofileghi; Begin Writeln; Write('File name data output: '); Readln(fo); Assign(fr,fo); {$i-} Rewrite(fr); {$i+} If (ioresult0) then Begin Write('Write protect error writing drive Enter to quit'); Readln; Close(f); Halt; End; End; Procedure MOFILEDOCindex; Var ok : Boolean; Begin Writeln; Repeat Write('File name index input : '); Readln(fin); Assign(findex,fin); {$i-} Reset(findex); {$i+} Ok:=(ioresult=0); If Not Ok Then Write('Error file data ',fin,' Enter to quit'); Until Ok; End; Procedure Mofileghiindex; Begin Writeln; Write('File name index : '); Readln(fin); Assign(findex,fin); {$i-} Rewrite(findex); {$i+} If (ioresult0) then Begin Write('Write protect error writing drive Enter to quit'); Readln; Close(f); Halt; End; End; Function SoNT(so:Longint):Boolean; Var i : Longint; Begin SoNt:=False; For i:=2 to Round(Sqrt(so))+1 If (so mod i=0) then Exit; SoNt:=True; End; Procedure GEN; Var i,so : Integer; f : Text; Begin Assign(f,fsnt); {$i-} ReWrite(f); {$i+} so:=0; For i:=130 to 300 If Sont(i*2+1) then Begin Inc(so); Writeln(f,i*2+1); If (so>=max) then Begin Close(f); Exit; End; End; Close(f); End; Procedure SNT; Var f : Text; Begin Writeln('Read data Pleas wait '); Repeat sosoNt:=0; Assign(f,Fsnt); {$i-} reset(f); {$i+} If (Ioresult0) then Begin Gen; Reset(f); End; While Not SeekEof(f) Begin Inc(sosont); Readln(f,a[sosont]); End; Close(f); If (sosont2); End; Procedure Sinh1PQ; Begin Randomize; Repeat Q:=Random(sosont)+1; P:=Random(sosont)+1; Until (pq) and (a[q]*a[p]0) Begin If (s1>s2) then s1:=s1 mod s2 Else s2:=s2 mod s1; End; If s1>s2 then UCLN:=s2 Else UCLN:=s1; End; Function NTCN(s1,s2 : Longint):Boolean; Begin While (s1 mod s20) and (s2 mod s10) and ((s1-1)*(s2-1)>0) Begin If (s1>s2) then s1:=s1 mod s2 Else s2:=s2 mod s1; End; If s1>s2 then NTCN:=s2=1 Else NTCN:=s1=1; End; Procedure Tinh4E; Begin For e:=1000 downto If NTCN(e,w) then Exit; End; Function Tinh(s1,s2,s3:Longint):Longint; Var Phu : Longint; Begin Phu:=0; While (s1>0) Begin If Odd(s1) Then Phu:=(Phu+s2) mod s3; s1:=s1 Shr 1; s2:=s2 shl 1; s2:=s2 mod s3; End; Tinh:=Phu mod s3; End; Function TinhPhu(s1,s2,s3 : Longint):Longint; Begin TinhPhu:=Round(s1*s2/s3); End; Procedure TIM(x,y : Longint; Var c,d:Longint); Var a,b,u,v,t,q,r : Longint; Begin a:=x; b:=y; c:=0; d:=1; u:=1; v:=0; q:=a div b; r:=a mod b; While (r0) Begin a:=b; b:=r; T:=u; u:=c; c:=T-q*c; T:=v; v:=d; d:=T-q*d; q:=a div b; r:=a mod b; End; End; Procedure Sinhd1; Var i : Longint; Begin d:=0; For i:=1 to 10000 If Tinh(i,w,e)=e-1 then Begin D:=i*(w div e)+(i*(w mod e)+1) div e; Exit; End; End; Procedure Sinhd; Var z : Longint; Begin Tim(e,w,d,z); If (d0) and (d= ) and Kt then Writeln('So la : ',So) Else Writeln(' Vo nghiem'); End; BEGIN Clrscr; TaoF; Nhap; Ketqua; Writeln('Da xong '); Readln; END Bài 14 : {$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q-,R-,S+,T-,V+,X+} {$M 16384,0,655360} Uses Crt; Const Fi = 'BANDO.INP'; Max = 70; Type Mab = Array[0 2*Max] of Byte; RV = Record Ch : Char; S,D : LongInt; End; MV = Array[1 2*Max] of RV; Md = Array[1 2*Max] of Boolean; Var A,B : Mab; V : MV; D : Md; F : Text; St1,St2 : String; Sv : Byte; Ms : RV; i : Byte; Procedure Init; Begin FillChar(A,Sizeof(A),0); FillChar(B,Sizeof(B),0); FillChar(D,Sizeof(D),False); End; Procedure Work; Var j : Byte; Line : LongInt; Begin Assign(F,Fi); {$I-} ReSet(F); {$I+} If IOresult then Begin Write('Error file input'); Halt; End; For i:=1 to Max St1:=St1+' '; Line:=0; Ms.S:=0; While not SeekEof(F) Begin St2:=St1; Readln(F,St1); Inc(Line); For i:=1 to Length(St1) If St2[i]=St1[i] then Begin B[i]:=A[i]; If St1[i]=St1[i-1] then If (i>1) and (B[i-1]B[i]) then Begin With V[B[i]] Begin S:=S+V[B[i-1]].S; If D>V[B[i-1]].D then D:=V[B[i-1]].D; End; D[B[i-1]]:=False; j:=i-2; While (j>0) and (B[j]=B[i-1]) Begin B[j]:=B[i]; Dec(j); End; B[i-1]:=B[i]; End; End Else If (i>1) and (St1[i]=St1[i-1]) then B[i]:=B[i-1] Else Begin j:=1; While D[j] Inc(j); D[j]:=True; With V[j] Begin Ch:=St1[i]; S:=0; D:=Line; End; B[i]:=j; End; FillChar(A,Sizeof(A),0); For i:=1 to Length(St1) Inc(A[B[i]]); For i:=1 to 2*Max If D[i] then If A[i]=0 then Begin D[i]:=False; If Ms.S