K
Khách

Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

ĐÁP ÁN VÒNG 2 CUỘC THI TIN HỌC: * ĐỀ 1: Câu 1: CÂU 1: const fi='uc.inp'; fo='uc.out'; var f: text; a,b,c : integer; function uc(x,y): integer; var z: integer; begin while y<>0 do begin z:=x mod y; x:=y; y:=z; end; uc:=x; end; procedure ip; begin assign(f,fi); reset(f); read(f,a,b,c); close(f); end; procedure out; begin assign(f,fo); rewrite(f); write(f,uc(uc(a,b),c); close(f); end; begin ip; out; end. Câu 2: const fi='SN.inp'; fo='SN.out'; var f:text; i,n:integer; s:real; procedure...
Đọc tiếp

ĐÁP ÁN VÒNG 2 CUỘC THI TIN HỌC:

* ĐỀ 1:

Câu 1:

CÂU 1:
const fi='uc.inp';
fo='uc.out';
var f: text;
a,b,c : integer;
function uc(x,y): integer;
var z: integer;
begin
while y<>0 do
begin
z:=x mod y;
x:=y;
y:=z;
end;
uc:=x;
end;
procedure ip;
begin
assign(f,fi);
reset(f);
read(f,a,b,c);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
write(f,uc(uc(a,b),c);
close(f);
end;
begin
ip;
out;
end.

Câu 2:

const fi='SN.inp';
fo='SN.out';
var
f:text;
i,n:integer;
s:real;
procedure ip;
begin
assign(f,fi);
reset(f);
read(f,n);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
s:=0;
for i:= 1 to n do
begin
if i mod 2 <> 0 then
s:=s+(i/(i+1));
if i mod 2 = 0 then
s:=s-(i/(i+1));
end;
write(f,s:0:2);
close(f);
end;
BEGIN
ip;
out;
END.

Câu 3:

const fi='SSNT.inp';
fo='SSNT.out';
var
f:text;
n,i,max,j:integer;
s:string;
a:array[1..32000] of integer;
function nt(x:integer):boolean;
var
i:integer;
begin
nt:=false;
if x < 2 then exit;
for i:= 2 to trunc(sqrt(x)) do
if x mod i = 0 then exit;
nt:=true;
end;
function snt(x:integer):boolean;
begin
snt:=false;
if x= 0 then exit;
while nt(x) = true do
x := x div 10;
if x = 0 then snt:=true;
end;
procedure ip;
begin
assign(f,fi);
reset(f);
max:=a[1];
readln(f,n);
for i:= 1 to n do
begin
read(f,a[i]);
if( a[i] < max ) and (nt(a[i]) = true) then
max:=a[i];
end;
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
writeln(f,max);
max:=0;
for i:= 1 to n do
begin
if snt(a[i]) = true then
begin
str(a[i],s);
if length(s) = 2 then
max:=max+a[i];
s:='';
end
else
a[i]:=-32000;
end;
writeln(f,max);
for i:= 1 to n-1 do
for j :=i+1 to n do
if a[i] > a[j] then
begin
max:=a[i];
a[i]:=a[j];
a[j]:=max;
end;
for i:= 1 to n do
if (a[i] > 0) and (a[i] <> a[i-1]) then write(f,a[i],' ');
close(f);
end;
BEGIN
ip;
out;
END.

CÂU 4:

const fi='TUOI.INP';
fo='TUOI.OUT';
var f: text;
a,b: byte;
procedure ip;
begin
assign(f,fi);
reset(f);
read(f,a,b);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
if (x=y*2) and (x>18) and (x-y>=18) then write(f,'CO') else write(f,x-y*2);
close(f);
end;
begin
ip;
out;
end.

const fi='CM.INP';

fo='CM.OUT';

var f: text;

a,n,b,k: integer;

a1: array[1..32000] of integer;

function nt(x: integer): boolean;

var i: integer;

begin

nt:=false;

if x<2 then exit;

for i:=2 to trunc(sqrt(x)) do if x mod i=0 then exit;

nt:=true;

end;

procedure ip;

begin

assign(f,fi);

reset(f);

read(f,n);

close(f);

end;

procedure out;

begin

assign(f,fo);

rewrite(f);

d:=0;

for a:=1 to k do

if nt(a) then

begin

inc(d);

a1[d]:=a;

end;

for a:=1 to d do

for b:=x to d do

if a1[a]+a1[b]=k then writeln(f,a1[a],'+',a1[b]);

end;

close(f);

end;

begin

ip;

out;

end.

*ĐỀ 2 :

BÀI LÀM CỦA BẠN LÊ HOÀNG THẮNG:

//----------------------------CAU 1--------------------------------

var s,d,n,i,u:longint;
a:array[0..32001] of longint;
f:text;
function ucln(x,y:longint):longint;
begin
if y=0 then exit(x) else exit(ucln(y,x mod y));
end;
begin
assign(f,'ucln.inp');reset(f);
readln(f,n);
for i:=1 to n do read(f,a[i]); close(f);
u:=a[1];
for i:=2 to n do u:=ucln(u,a[i]);
assign(f,'ucln.out');rewrite(f);
write(f,'UCLN: ',u,'; UC: ');
for i:=1 to u do if u mod i=0 then
begin
if i<>u then write(f,i,',') else write(f,i);
if i<10 then inc(d) else inc(s,i);
end;
writeln(f);
writeln(f,d); write(f,s);
close(f);
end.

//----------------------------CAU 2--------------------------------

var n,i:longint;
s:real;
f:text;
begin
assign(f,'sn.inp');reset(f);
readln(f,n); close(f);
for i:=1 to n do if odd(i) then s:=s-i/(i+1) else s:=s+i/(i+1);
assign(f,'sn.out');rewrite(f);
write(f,s:0:2);
close(f);
end.

//----------------------------CAU 3--------------------------------

var a:array[0..1000000] of boolean;
b:array[0..1000000] of longint;
i,j,k,n,d:longint;
f:text;
procedure taosang(n:longint);
var i,j:longint;
begin
for i:=2 to trunc(sqrt(n)) do if not(a[i]) then
begin
j:=i*i;
while j<=n do begin a[j]:=true; inc(j,i); end;
end;
end;
begin
assign(f,'boso.inp');reset(f);
readln(f,n); taosang(n); close(f);
assign(f,'boso.out');rewrite(f);
for i:=2 to n do if not(a[i]) then
begin
inc(d);
b[d]:=i;
end;
for i:=1 to d do
for j:=i to d do
if (n-b[i]-b[j]>=b[j]) and not(a[n-b[i]-b[j]]) then
writeln(f,b[i],' ',b[j],' ',n-b[i]-b[j]);
close(f);
end.

//----------------------------CAU 4--------------------------------

THAM KHẢO ĐỀ 1.

//----------------------------CAU 5--------------------------------

var n,i,s,t:longint;
f:text;
begin
assign(f,'u.inp');reset(f);
readln(f,n); t:=n; close(f);
assign(f,'u.out');rewrite(f);
for i:=2 to trunc(sqrt(n)) do
begin
if n mod i=0 then
begin
write(f,i,' ');
repeat n:=n div i until n mod i>0;
end;
if t mod (i*i)=0 then inc(s,i*i);
end;
writeln(f);
write(f,s+1);
close(f);
end.

*ĐỀ CHUNG:

BÀI LÀM CỦA BẠN ĐÀO XUÂN SƠN :

Câu 1:

const fi='TCS.inp';
fo='TCS.out';
var
f:text;
x:char;
tg:byte;
s:integer;
CODE:integer;
procedure ip;
begin
assign(f,fi);
reset(f);
s:=0;
while not(eof(f)) do
begin
read(f,x);
if x in ['0'..'9'] then
begin
val(x,tg,CODE);
s:=s+tg;
end;
end;
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
write(f,s);
close(f);
end;
BEGIN
ip;
out;
END.

Câu 2:

const fi='t.inp';
fo='t.out';
var
f:text;
s:string;
i:byte;
procedure ip;
begin
assign(f,fi);
reset(f);
read(f,s);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
s[1]:=upcase(s[1]);
for i:= 2 to length(s) do
if s[i-1] <> #32 then
s[i]:=lowercase(s[i]) else
s[i]:=upcase(s[i]);
write(f,s);
close(f);
end;
BEGIN
ip;
out;
END.

1
8 tháng 1 2020

Em dốt tin lắm cô ơi, cô tạo khóa học nào đi, cô còn kèm em học yeu

ĐÁP ÁN VÒNG 1 CUỘC THI TIN HỌC Câu 1: const fi='tong.inp'; fo='tong.out'; var f:text;i,n:integer;t:real; procedure ip; begin assign(f,fi); reset(f); readln(f,n); t:=abs(sqrt(4)*1/2); for i:= 1 to n do t:=t+(i/(i+1)); close(f); end; procedure out; begin assign(f,fo); rewrite(f); write(f,t:0:3); close(f); end; BEGIN ip; out; END. Câu 2: Bài làm của bạn Lê Hoàng Thắng : var a:array[1..10000000] of longint; min,vtmin,vtmax,n,i,k,demk,max,sum:longint;...
Đọc tiếp

ĐÁP ÁN VÒNG 1 CUỘC THI TIN HỌC

Câu 1:

const fi='tong.inp';

fo='tong.out';

var

f:text;i,n:integer;t:real;

procedure ip;

begin

assign(f,fi);

reset(f);

readln(f,n);

t:=abs(sqrt(4)*1/2);

for i:= 1 to n do

t:=t+(i/(i+1));

close(f);

end;

procedure out;

begin

assign(f,fo);

rewrite(f);

write(f,t:0:3);

close(f);

end;

BEGIN

ip;

out;

END.

Câu 2: Bài làm của bạn Lê Hoàng Thắng :

var a:array[1..10000000] of longint; min,vtmin,vtmax,n,i,k,demk,max,sum:longint; sm:boolean;
function nguyento(x:longint):boolean;
var demuoc,t:longint;
begin
demuoc:=0;
for t:=1 to x do if (x mod t = 0) then inc(demuoc);
if demuoc=2 then nguyento:=true else nguyento:=false;
end;
function hoanhao(y:longint):boolean;
var tong,g:longint;
begin
tong:=0;
for g:=1 to y-1 do if (y mod g=0) then tong:=tong+g;
if tong=y then hoanhao:=true else hoanhao:=false;
end;
begin
assign(input,'mang.inp'); reset(input);
assign(output,'mang.out'); rewrite(output);
readln(n); readln(k); demk:=0;
for i:=1 to n do read(a[i]);
min:=a[n];
for i:=n downto 1 do if a[i]<min then begin min:=a[i]; vtmin:=i; end;
max:=abs(a[1]);
for i:=1 to n do if abs(a[i])>max then begin max:=abs(a[i]); vtmax:=i; if a[i]<0 then sm:=true else sm:=false; end;
for i:=1 to n do if (k=a[i]) then inc(demk);
sum:=0;
for i:=1 to n do
begin
if (nguyento(a[i]) or hoanhao(a[i])) then sum:=sum+a[i];
end;
writeln(vtmin);
if sm=false then writeln(max,' ,vi tri: ',vtmax) else writeln('-',max,' ,vi tri: ',vtmax);
if (demk=0) then writeln('khong, so lan xuat hien :0') else writeln('co, so lan xuat hien :',demk);
write(sum);
close(input); close(output);
end.

Câu 3: Bài làm của bạn Lê Hoàng Thắng:

const fi='xau.inp';

fo='xau.out';

var s1,s2:string; match,i:longint; f: text;

procedure ip;

begin
assign(f,fi); reset(f);
readln(s1); read(s2);

close(f);

end;

procedure out;

begin

assign(f,fo); rewrite(f);
match:=0;
if s1=s2 then begin write('KHONG'); exit; end;
for i:=1 to length(s1) do
begin
if s1[i]=s2[i] then inc(match);
end;
if match=length(s1)-2 then write('CO') else write('KHONG');
close(f);

end;

Begin

ip;

out;
end.

Câu 4: Bài làm của bạn Đào Xuân Sơn :

const fi='STN.inp';
fo='STN.out';
var
f:text;
s:string;
n,t,i:integer;
function dx(x:string):boolean;
var
i:byte;
begin
dx:=false;
for i:= 1 to length(x) div 2 do
if x[i] <> x[length(x)-i+1] then
exit;
dx:=true;
end;
procedure ip;
begin
assign(f,fi);
reset(f);
read(f,n);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
str(n,s);
if dx(s) = true then writeln(f,'CO') else writeln(f,'KHONG');
t:=0;
for i:= 1 to n div 2 do
if n mod i = 0 then t:=t+i;
if t=n then
begin
write(f,'CO,');
t:=0;
while n<>0 do
begin
t:=t+(n mod 10);
n:=n div 10;
end;
writeln(f,' ',t);
end else
writeln(f,'KHONG');
write(f,length(s));
close(f);
end;
BEGIN
ip;
out;
END.

Bài 5: Bài làm của bạn Vinh Lê:

const fi=’tich.inp’;

fo=’tich.out’;

var f: text;

a,b: integer;

procedure ip;

begin

assign(f,fi);

reset(f);

readln(f,a);

read(b);

close(f);

procedure out;

begin

assign(f,fo);

rewite(f);

t:=a;

t:=t*b;

write(f,t);

close(f);

end;

Begin

ip;

out;

end.

Đây là các bộ code sử dụng thuật toán hoàn chỉnh nhất và tối ưu.

1
25 tháng 7 2019

thiệt ko vậy

18 tháng 3 2021

Giúp mình vs

18 tháng 3 2021

a) tính tổng các số chẵn từ 1 đến 50
b)
  (3): lệnh viết kq của ct trên.
  (4):lệnh in ra màn hình kq của bài toán.
  (5):lệnh kết thúc ct.

BÀI THỰC HÀNHTuần 25 (Tiết 1)Bài 1: Cho mãng gồm n phần tử là số thực.a.Tìm hai phần tử liên tiếp nhau có tổng bằng n.b. Tính khoảng cáhc giữa hai vị trí của phần tửlớn nhất và bé nhất đầu tiên trên A.{Chương trình}Program Tuan25_Bai1;Uses crt;VarA: array[1…..100] of real;Max, min : realI, n, Vtmax, Vtmin = integer;BeginWriteln(‘nhap n:’); readln(n);For i: 1 to n do;BeginWrite(‘[‘,I,’]=’); readln(A[i]);End.i:=1;{Tìm...
Đọc tiếp

BÀI THỰC HÀNH

Tuần 25 (Tiết 1)

Bài 1: Cho mãng gồm n phần tử là số thực.

a.Tìm hai phần tử liên tiếp nhau có tổng bằng n.

b. Tính khoảng cáhc giữa hai vị trí của phần tửlớn nhất và bé nhất đầu tiên trên A.

{Chương trình}

Program Tuan25_Bai1;

Uses crt;

Var

A: array[1…..100] of real;

Max, min : real

I, n, Vtmax, Vtmin = integer;

Begin

Writeln(‘nhap n:’); readln(n);

For i: 1 to n do;

Begin

Write(‘[‘,I,’]=’); readln(A[i]);

End.

i:=1;

{Tìm hai phần tử liên tiếp nhau có tổng bằng n}

While (A[i] + A[i+1]) <> n) and (i<= n-1) do i:=i+1

If i>=n then write (‘hai phan tu co chi so la:’,i,’ va’,i+1);

{Tính khoảng cáhc giữa hai vị trí của phần tử lớn nhất và bé nhất đầu tiên trên A}

Max=A[1];

Min:A[1];

For i:1 to n do

If max < A[i] then

Begin

Vtmax:= i; Max:=A[i];

End

If min > A[i] then

Begin

Vtmin: i; Min=A[i];

End

Writeln (‘khoangr cach giua 2 phan tu max vaf min la:’,abs(Vtmax – Vtmin));

Readln;

End

1
2 tháng 3 2022

???!!!

Không đúng nha bạn

26 tháng 2 2021

Program HOC24;

var i,n,s: integer;

begin

writeln('Chuong trinh tinh tong S = 1 + 2 +3 +...+ n');

write('Nhap so n;'); readln(n);

s:=0; i:=1;

while i<n do

begin

s:=s+i;

i:=i+1;

end;

writeln('Tong cua ',n,' so tu nhien dau tien s = ',s);

readln

end.

uses crt;

var i,n,s:integer;

begin

clrscr;

write('Nhap n='); readln(n);

s:=0;

i:=0;

while i<=n do 

begin

i:=i+1;

s:=s+i;

end;

writeln(s);

readln;

end.

20 tháng 10 2018

chắc có hoặc ko?

20 tháng 10 2018

ha