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

HDC de thi chon HSG THPT cap tinh nam 2008 2009 nam Tin hoc

6 5 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 6
Dung lượng 389,48 KB

Nội dung

B, Hudng dan ch$m phiin viet chuung trinh va thuat toan.[r]

(1)

S& GD - DT LAO CAI

D$ THI CHINH THOC

KV THI HOC SINH GIOI CAP T ~ N H L ~ P 12 NAM HOC : 2007-2008

~ N DAN GC H ~ I - M ~ N : Tin hoe

( Hu6ng ddn chc4m gdm trang )

A, TEST: Ph$n thi l$p trhh CSlu 1: ( 7 di6m )

Did

m

1

1

1

1

1

1

1 Output

DAYSO.0UT

a So tu xau st:

b Ky tu c xuat hien lan, vi tri xuat hien dau tien c Co 1 tu duoc bat dau boi ky tu t hoac ky a T d Ki tu N xuat hien nhieu nhat

a So tu xau st: 8

b Ky tu c xuat hien lan, vi tri xuat hien dau tien 17 c Khong co tu nao duoc bat dau boi ky tu t hoac ky tu T d Ki tu A xuat hien nhieu nhat

a So tu xau st:

b Ky tu c xuat hien Ian, vi tri xuat hien dau tien c Co 1 tu duoc bat dau boi ky tu t hoac ky tu T d Ki tu H xuat hien nhieu nhat

a So tu xau st:

b Ky tu c xuat hien lan, vi tri xuat hien dau tien 16 c Co tu duoc bat dau boi ky tu t hoac ky tu T d Ki tu 0 xuat hien nhieu nhat

a So tu xau st:

b Ky tu c khong xuat hien xau

c Khong co tu nao duoc bat dau boi ky tu t hoac ky tu T d Ki tu N xuat hien nhieu nhat

a So tu xau st:

b Ky tu c khong xuat hien xau

c Co tu duoc bat dau boi ky tu t hoac ky tu T d Ki tu A xuat hien nhieu nhat

a So tu xau st:

b Ky tu c khong xuat hien xau

c Co 1 tuduocbatdauboi kytu thoac kytuT d Ki tu N xuat hien nhieu nhat

Test

1

2

3

4

5

6

7

Input DAYSO.INP

Tin can ban

'Ong hoi chu nghia Narn

Doc lap tu hanh phuc

truong trung hoc thong so

nguyen van an

tran ba hoang

(2)

C l u 2: ( di&m ) DCTANG.PAS

C l u 3:( diim ) MUAVE-PAS Test

1

3

6

7

Output DAYCON.OUT

Day tang lon nhat gom pt: 1 3

Day tang lon nhat gom pt: 23 31 Day tang lon nhat gom pt: 23 65 76

Day tang lon nhat gom 0 pt:

-

Day tang lon nhat gom pt: 5 6 7

Day tang lon nhat gom pt:

7 9 23

Day tang Lon nhat gom pt: 3 4 5 6

Input DAYCON.I[NP 7

4 2 4

233121209 10

965213423657643 24 27

5

2 2 2 8

4321 2 15

2 6 3 3

13

2 6 3

Test

1

2

3

4

5

6

Di6 m

1 1

1

Input

Luoi.inp

5

2 4

3 9 10 10

4

3

6

7

7 6 2 4 1 9 8

12 3 12 6 3

3

4 10 6

6

34 54 23 12 4 3

21 23 45 3 13

2

3 6

Output

Luoi.out

17 2 4

7 2 4 22 2

10

3

63 2 6 2

Didm

1

1

1

1

1

(3)

B, Hudng dan ch$m phiin viet chuung trinh va thuat toan ( gbm 4 trang )

Hudng d&n chung

Thu& t d n hqp 19: 1 didm

Khai Mo bign, h h g hqp 19: 0.5 didm

Khai biio d c chucmg trinh hqp 19: 0.5 didm

EM cuc chucmg trinh h q ~ 19: 0.5 didm

C l u ( 2.5 diem ) program bail; uses crt; Const

fi='c:\xau.inp' ;

fo='c:\xau.outl; var

st: string;

d: array[1 100] of integer; f,fl:text;

{ - - - - - doc du lieu - I Procedure nhap;

Var i,dem j,k,t,dl,d2,il:integer; ch:char;

vt:array[l SO] of integer; luu: string;

Begin

assign(f,fi); reset(f); assign(fl,fo); rewrite(f1); read(f,st);

Writeln(' Xau st: ',st); { - dem tu -I st := ' ' + st;

dem := 0;

for i := to length(st)

if (st[i] = ' ') and (st[i+l] o ' ') then dem := dem + 1; Writeln(fl,' a So tu xau st: ',dem);

{ - - - kiem tra ky tu c -I delete(st,l,l);

il:= 0; dl:=O;

for i := to length(st) if st[i] = 'c' then

Begin inc(d1); inc(i1); vt[il] := i; end; if d l > then

Writeln(f1,' b Ky tu c xuat hien ',dl, ' lan, vi tri xuat hien dau tien ',vt[l]) else

Writeln(f1,' b Ky tu c khong xuat hien xau'); d2 :=O; st := ' ' + st;

for i := to length(st)

(4)

if d2 > then

Writeln(f1,' c Co ',d2,' tu duoc bat dau boi ky tu t hoac ky tu T') else

Writeln(f1,' c Khong co tu nao duoc bat dau boi ky tu t hoac ky tu T'); { - dem ki tu xuat hien nhieu nhat xau -I

k:=O; j:= 0;

for ch := 'A' to '2' do begin

for i := to length(st)

if upcase(st[i]) = ch then inc(k); if j < k then

begin j := k; luu := ch; end; k := 0; end;

W r i t ! ~ 1 l h ' , h l l , h m ~ ~ ' & - -

Close(f); Close(f1); End;

{ - - - - - - - 1

BEGIN clrscr ;

nhap; readln; END

C i u ( 2.5 di&m ) DAYCT.PAS program day-con-tang ;

uses crt ;

Const fi = 'c:\dayso.inpt; fo = 'c:\dayso.out';

type mang = array[l 50] of longint; var a, a1:mang ;

n:integer ;

f,fl:text ;

{ - - - - - - - nhap du lieu -

I

p r o c e d u S ~ n p u t ; - - -

var i:integer ;

begin

as&!!n(f,fi) ;

reset(f) ;

Writeln('Doc day so:'); readln(f,n) ;

writeln(n) ;

for i:=l to n begin

read(f,a[i]) ;

write(a[i],' ');

(5)

end;

{ - x u ly - 1

procedure daytang;

Var i j,dem,max,vtl,vt2:integer; Begin

dem := 1; max := 0;

for i := to n-1 if a[i]ca[i+l] then

begin

j := i;

while (au] c alj+l]) and (j <= n) Begin

inc(dem); inc(j); end;

if max c dem then Begin

max := dem; vtl:= i;

vt2:= j;

end; dem := 1; end; Writeln;

Write(' Day tang Ion nhat gom: ',max,' phan tu: ');

for i := vtl to vt2

Write(a[i]:4);

{ - - - Ghi file }

assign(f1,fo) ;

Rewrite(f1) ;

Writeln;

Write(f1,'Day tang Ion nhat gom ',max,' pt:'); for i := vtl to vt2

Write(fl,a[i]:4); Close(f1);

end; begin

clrscr ;

input; daytang; readln ;

end

Cilu (2.5 di6m) Program muave; Uses crt;

const inp='c:huave.inp1; out= 'c:\muave.out'; max = 100;

Var f,t,R: Array[O max+l] of Integer;

(6)

( - - - - - - - - Input - 1 Procedure nhap; Var i:integer;

fl:text; Begin

Assign(fl,inp); Reset(fi) ;

Readln(fi,N); for i := to N Read(fl,t[il);

for i := to N - 1 Read(fl,R[i]);

close(fl); End;

{ - - - - - x u ly - 1

Procedure Solve; Var i : integer; Begin

R[O]:= 0 ;

no] := 0; fCl] := T[1];

Fillc har (pass,sizeof(pass),O); For i := 2 to n

if fli-2]+ R[i-11 c T[i] + fli-11 then Begin

pass[i] := True; pass[i-1] := False; f[i] := fli-21 + R[i-11 end

Else

fCi] := T[i] + fCi-11; end;

( -.-xuat -. 1 Procedure xuat; Var

i:integer; fo:text; begin

Assign(fo,out); Rewrite(f0); Writeln(fo,f[N]); For i := to N

if pass[i] then Write(fo,i,' ');

close(f0); End;

{ - - - - - - - - 1 Begin

Clrscr ;

nhap; Solve; xuat; readln ;

Ngày đăng: 30/04/2021, 20:31

w