1. Trang chủ
  2. » Giáo án - Bài giảng

Bài giải HSG 9 tin học 2010-2011 tinh Vĩnh Phúc

4 134 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 4
Dung lượng 27 KB

Nội dung

Bi 1 Uses Crt; Const Fi='Blimp.INP'; Fo='Blimp.OUT'; Type MA=Array[1 10] Of String[15]; Var s:MA; F,G:Text; i,n,d,k,j:Integer; Procedure Nhap; Begin Assign(F,Fi);Reset(F); ReadLn(F,n); For i:=1 To n Do ReadLn(F,S[i]); Close(F); End; Procedure Xu_ly; Begin Assign(G,Fo);ReWrite(G); d:=0; For i:=1 To n Do Begin k:=0; For j:=1 To LengTh(S[i]) Do If (S[i][j] in ['A' 'Z']) Or (S[i][j] in ['0' '9']) Or (S[i] [j] in ['-']) Then k:=k+1; If (k=LengTh(S[i])) And (Pos('FBI',S[i])<>0) Then Begin Write(G,i:3); d:=d+1; End; End; If d=0 Then Write(G,'GO'); Close(G); End; BEGIN Nhap; Xu_ly; END. Bi 2: Uses Crt; Const Fi='lexdiv.inp'; Fo='lexdiv.out'; Type MA=Array[1 100] Of String; Var i,i1,j1,j2,a,b,k,m:Integer; s,tg:String; F,G:Text; c:MA; Procedure Nhap; Begin Assign(F,Fi);Reset(F); ReadLn(F,A,B,K); Close(F); End; Procedure Xu_ly; Begin Assign(G,Fo);ReWrite(G); m:=0; For i:=A To B Do If i Mod k = 0 Then Begin m:=m+1; Str(i,s); c[m]:=s; End; For j1:=1 To m Do For j2:=j1+1 To m Do Begin i1:=1; While c[j1][i1]=c[j2][i1] Do i1:=i1+1; If c[j1][i1]>c[j2][i1] Then Begin tg:=c[j1]; c[j1]:=c[j2]; c[j2]:=tg; End; End; Write(G,c[1]:5); Close(G); End; BEGIN Nhap; Xu_ly; END. Bi 3: Uses Crt; Const Fi='prison.INP'; Fo='prison.OUT'; Type MA=Array[1 100] Of Integer; Var A:MA; F,G:Text; s,n,i,j1,j,kt,d,m,k:Integer; Procedure Nhap; Begin Assign(F,Fi);Reset(F); ReadLn(F,S,N); Close(F); End; Procedure Xu_ly; Begin If S Mod 2 =0 Then m:=s*(s*2-1)-1 Else m:=s*(s*2-1); A[1]:=0; A[2]:=2*s-1; For j:=3 To s Do A[j]:=A[j-1]*2-A[j-2]; A[s+1]:=s-1; A[s+2]:=2*A[s+1]+s; For j1:=s+3 To 2*s Do A[j1]:=A[j1-1]*2-A[j1-2]; kt:=0; For i:=1 To 2*s Do If n=A[i] Then kt:=kt+1; If (kt=0) Then Begin If ((n-2*s+1)>=0)And(n-2*s+1<=m)Then Write(G,n-2*s+1:5); If (n-s>=0)And(n-s<=m)Then Write(G,n-s:5); If (n-s+1>=0)And(n-s+1<=m)Then Write(G,n-s+1:5); If (n+s-1>=0)And(n+s-1<=m)Then Write(G,n+s-1:5); If (n+s>=0)And(n+s<=m)Then Write(G,n+s:5); If (n+2*s-1>=0)And(n+2*s-1<=m)Then Write(G,n+2*s-1:5); End Else Begin d:=0; k:=1; While n<>A[k] Do Begin k:=k+1; d:=k; End; If k=1 Then Write(G,n+s:5,n+2*s-1:5) Else If k=s Then Write(G,n-2*s+1:5,n-s+1:5,n+s:5) Else If k=s+1 Then Write(G,n+s-1:5,n+2*s-1:5) Else If k=2*s Then Write(G,n-2*s+1:5,n-s:5,n+s-1) Else If (k>1)and(k<s)Then Write(G,n-2*s+1:5,n-s+1:5,n+s:5,n+2*s-1:5) Else Write(G,n-2*s+1:5,n-s:5,n+s-1:5,n+2*s-1:5); End; End; BEGIN Nhap; Xu_ly; END. . LengTh(S[i]) Do If (S[i][j] in ['A' 'Z']) Or (S[i][j] in ['0' &apos ;9& apos;]) Or (S[i] [j] in ['-']) Then k:=k+1; If (k=LengTh(S[i])) And (Pos('FBI',S[i])<>0)

Ngày đăng: 28/06/2015, 01:00

TỪ KHÓA LIÊN QUAN

w