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.
![](https://rs.olm.vn/images/avt/0.png?1311)
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.
![](https://rs.olm.vn/images/avt/0.png?1311)
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.
![](https://rs.olm.vn/images/avt/0.png?1311)
uses crt;
const fi='dayso.txt';
fa='tong.txt';
fb='kq.txt';
var f1,f2,f3:text;
a:array[1..100]of integer;
n,i,t,kt,j:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
assign(f2,fa); rewrite(f2);
assign(f3,fb); rewrite(f3);
n:=0;
while not eof(f1) do
begin
n:=n+1;
readln(f1,a[n]);
end;
{--------------------------cau-a--------------------------}
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln(f2,'tong cua day so la: ',t);
{--------------------------cau-b--------------------------}
writeln(f3,'cac so chan trong day la: ');
for i:=1 to n do
if a[i] mod 2=0 then write(f3,a[i]:4);
writeln(f3);
writeln(f3,'cac so le trong day la: ');
for i:=1 to n do
if a[i] mod 2<>0 then write(f3,a[i]:4);
{--------------------------cau-c--------------------------}
writeln('cac so nguyen to trong day la: ');
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to a[i]-1 do
if a[i] mod j=0 then kt:=1;
if kt=0 then write(a[i]:4);
end;
close(f1);
close(f2);
close(f3);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
Câu 1:
const fi1='nguyen1.inp';
fi2='nguyen2.inp';
fo='songuyen.inp';
var f1,f2,f3:text;
a:array[1..10000]of integer;
i,dem:integer;
begin
assign(f1,fi1); reset(f1);
assign(f2,fi2); reset(f2);
assign(f3,fo); rewrite(f3);
dem:=0;
while not eof(f1) do
begin
inc(dem);
read(f1,a[dem]);
end;
while not eof(f2) do
begin
inc(dem);
read(f2,a[dem]);
end;
for i:=1 to dem do
write(f3,a[i]:4);
close(f1);
close(f2);
close(f3);
end.
Câu 2:
uses crt;
const fi='vanban.txt';
var f1:text;
st:array[1..255]of string;
dem:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
dem:=0;
while not eof(f1) do
begin
inc(dem);
readln(f1,st[dem]);
end;
writeln('So dong cua tep ',fi,' la: ',dem);
close(f1);
readln;
end.
Câu 3:
const fi='nguon.txt';
fo='dich.txt';
var f1,f2:text;
st:array[1..255]of string;
i,dem:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
dem:=0;
while not eof(f1) do
begin
inc(dem);
readln(f1,st[dem]);
end;
for i:=1 to dem do
writeln(f2,st[i]:4);
close(f1);
close(f2);
end.
Câu 4:
const fi='dulieu.int';
fo='sochan.out';
var f1,f2:text;
a:array[1..255]of integer;
i,dem:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
dem:=0;
while not eoln(f1)do
begin
inc(dem);
read(f1,a[dem]);
end;
for i:=1 to dem do
if a[i] mod 2=0 then write(f2,a[i]:4);
close(f1);
close(f2);
end.
Câu 5:
const fi='dulieu.int';
fo='dulieu.out';
var f1,f2:text;
a:array[1..255]of integer;
i,n,tam,j: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]);
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]<a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
for i:=1 to n do
write(f2,a[i]:4);
close(f1);
close(f2);
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
Var f1, f2: text;
Tong, m, n, i: integer;
Begin
assign(f1, ‘DULIEU.TXT’);
reset(f1);
assign(f2, ‘KETQUA’);
rewrite(f2);
Tong;= 0;
read(f1, m, n);
for i:= m to n do
if i mod 2 = 0 then Tong:= Tong+i;
write(f2, Tong);
close(f1);
close(f2);
End.
![](https://rs.olm.vn/images/avt/0.png?1311)
Var f1, f2: text;
Tong, m, n, i: integer;
Begin
assign(f1, ‘DULIEU.TXT’);
reset(f1);
assign(f2, ‘KETQUA’);
rewrite(f2);
Tong;= 0;
read(f1, m, n);
for i:= m to n do
if i mod 2 = 0 then Tong:= Tong+i;
write(f2, Tong);
close(f1);
close(f2);
End.
![](https://rs.olm.vn/images/avt/0.png?1311)
#include <bits/stdc++.h>
using namespace std;
long long i,a[100],n;
int main()
{
freopen("songuyen.txt","r",stdin);
n=20;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
var a,b:text;
s:integer;
begin
assign(a,'number.txt');
assign(b,'KQ.txt');
reset(a);
rewrite(b);
while not eof(a) do
begin
read(a,s);
if s mod 3 =0 then
writeln(b,'s=',s,s:3);
end;
close(a);
close(b);
readln
end.