Chủ Nhật, 31 tháng 12, 2017

Hướng đẫn giải, Đề thi học sinh giỏi lớp 9 môn Tin học, huyện Trảng Bom, tỉnh Đồng Nai, năm học 2016 - 2017

Mời các bạn tham khảo hướng dẫn giải
Đề thi học sinh giỏi lớp 9 môn Tin học, huyện Trảng Bom, tỉnh Đồng Nai, năm học 2016 - 2017
----------

Bài UOCSO

const fi='uocso.inp';
        fo='uocso.out';
var n:longint;
        s:int64;
procedure xuli;
        var i:longint;
        begin
                for i:=1 to n do
                        if n mod i=0 then
                                begin
                                write(i,' ');
                                s:=s+i;
                                end;
                writeln;
                writeln(s);
        end;
begin
assign(input,fi);
reset(input);
assign(output,fo);
rewrite(output);
        readln(n);
        xuli;
end.

Bài MAX_SORT

const fi='Max_Sort.inp';
        fo='Max_Sort.out';
var a:array[0..1000] of longint;
        n:longint;
procedure nhap;
        var i:longint;
        begin
                readln(n);
                for i:=1 to n do read(a[i]);
        end;
procedure sapxep;
        var i,t,j:longint;
        begin
                for i:=1 to n do
                for j:=i+1 to n do
                        if a[i] < a[j] then
                                begin
                                t:=a[i];
                                a[i]:=a[j];
                                a[j]:=t;
                                end;
        end;
procedure xuat;
        var i:longint;
        begin
                writeln(a[1]);
                for i:=1 to n do write(a[i],' ');
        end;
begin
assign(input,fi);
reset(input);
assign(output,fo);
rewrite(output);
        nhap;
        sapxep;
        xuat;
end.

Bài HOTEN

const
        fin='hoten.inp';fon='hoten.out';
var s,s1:string;i,j,n,m,k,l:longint;
begin
assign(input,fin);
reset(input);
assign(output,fon);
rewrite(output);
readln(s);
i:=1;
while s[i]=' ' do inc(i);
delete(s,1,i-1);
i:=length(s);
while s[i]=' ' do dec(i);
delete(s,i+1,length(s)-i);
s1:='';
s1:=s1+upcase(s[1]);
i:=2;
while i<=length(s) do
        begin
        if (s[i]=' ') and (s[i-1]=' ')  then
                begin
                while s[i]=' ' do inc(i);
                s1:=s1+upcase(s[i]);
                end
        else
                begin
                if s[i-1]<>' ' then
                        s1:=s1+ lowercase(s[i])
                else s1:=s1+upcase(s[i]);
                end;
        inc(i);
        end;
l:=0;
for i:=1 to length(s1) do
        if s1[i]=' ' then inc(l);
writeln(l+1);
writeln(s1);
close(input);close(output);
end.

Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.