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.

Bài 1:

const fi='so.inp';
fo='so.out';
var f1,f2:text;
a:array[1..100]of integer;
dem,i,t:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
dem:=0;
while not eof(f1) do
begin
inc(dem);
readln(f1,a[dem]);
end;
writeln(f2,'Cac so nguyen am la: ');
for i:=1 to dem do
if a[i]<0 then write(f2,a[i]:4);
writeln(f2);
t:=0;
for i:=1 to dem do
if (a[i] mod 5=0) and (a[i] mod 3=0) then t:=t+a[i];
writeln(f2,'Tong cac so chia het cho 3 va 5 la: ',t);
close(f1);
close(f2);
end.

Bài 2:

uses crt;
const fi='baitap.txt';
fo='kq.qut';
var f1,f2:text;
a:array[1..100]of integer;
dem,i,n:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
n:=0;
while not eoln(f1) do
begin
inc(n);
read(f1,a[n]);
end;
dem:=0;
for i:=1 to n do
if a[i] mod 5=0 then dem:=dem+1;
writeln('So luong cac so chia het cho 5 la: ',dem);
for i:=1 to n do
if sqrt(a[i])=trunc(sqrt(a[i])) then write(f2,a[i]:4);
close(f1);
close(f2);
readln;
end.

18 tháng 2 2021

Program HOC24;

const fi='DL.INP';

fo='DL.OUT';

var s: string;

d,i: byte;

f: text;

procedure ip;

begin

assign(f,fi);

reset(f);

read(f,s);

close(f);

end;

procedure out;

begin

assign(f,fo);

rewrite(f);

d:=0;

for i:=1 to length(s) do if s[i] in ['0'..'9'] then inc(d);

write(f,d);

close(f);

end;

begin

ip;

out;

end.

const fi='dl.inp';

fo='kq.out';

var f1,f2:text;

s:string;

d,i,dem:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,s);

d:=length(s);

dem:=0;

for i:=1 to d do 

  if s[i] in ['0'..'9'] then inc(dem);

writeln(dem);

readln;

end.

uses crt;

const fi='songuyen.inp';

fo='songuyen2.out';

var a:array[1..100]of integer;

i,n,t1:integer;

f1,f2:text;

begin

clrscr;

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,n);

for i:=1 to n do readln(f1,a[i]);

t1:=0;

for i:=1 to n do if a[i] mod 2<>0 then t1:=t1+a[i];

writeln(t1);

writeln(f2,t1);

for i:=1 to n do 

  if a[i] mod 2<>0 then write(a[i]:4);

close(f1);

close(f2);

readln;

end.

uses crt;

const fi='data.txt';

var f1:text;

a:array[1..100]of integer;

n,i:integer;

begin

clrscr;

assign(f1,fi); reset(f1);

n:=0;

while not eof(f1) do 

  begin

n:=n+1;

read(f1,a[n]);

end;

for i:=1 to n do 

  if a[i] mod 2=0 then write(a[i]:4);

close(f1);

readln;

end.

uses crt;

const fi='input.txt';

fo='output.txt';

var f1,f2:text;

a,b:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,a,b);

if (a=0) and (b=0) then writeln(f2,'Phuong trinh co vo so nghiem');

if (a<>0) then writeln(f2,-b/a:4:2);

if (a=0) and (b<>0) then writeln(f2,'Phuong trinh vo nghiem');

close(f1);

close(f2);

end.

3 tháng 3 2021

a)

PROGRAM BAI1a;

VAR N, Tle, Tchan: integer;

BEGIN

          Write ('Nhap N =');

          Readln (N);

          If (N mod 2) = 0 Then

          Tle := N*((N - 2)/2 + 1)/2;

          Tchan := (N + 2)*((N - 2)/2 + 1)/2;

          If (N mod 2) = 1 Then

          Tle := (N + 1)*((N-1)/2 +1)/2;

          Tchan := (N + 1)*((N - 3)/2 + 1)/2;

          WRITELN ('Sle =', Sle, 'Schan =', Schan);

          READLN;

          END.

30 tháng 12 2021

1:

uses crt;

const fi='songuyen.doc';

var i:integer;

f1:text;

begin

clrscr;

assign(f1,fi); rewrite(f1);

for i:=1 to 10 do write(f1,i:4);

close(f1);

readln;

end.

const fi='songuyen.dat';

fo='ketqua.dat';

var f1,f2:text;

a:array[1..100]of integer;

i,n,s,ln:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,n);

for i:=1 to n do 

read(f1,a[i]);

s:=1;

ln:=a[1];

for i:=1 to n do

begin

s:=s*a[i];

if ln<a[i] then ln:=a[i];

end;

writeln(f2,s);

writeln(f2,ln);

close(f1);

close(f2);

end.

uses crt;

const fi='mang.inp';

var f1:text;

a:array[1..10000]of integer;

i,n:integer;

begin

clrscr;

assign(f1,fi); reset(f1);

n:=0;

while not eof(f1) do 

begin

n:=n+1;

read(f1,a[i]);

end;

for i:=1 to n do write(a[i]:4);

close(f1);

readln;

end.