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.
const fi='dulieu.txt';
fo='ketqua.txt';
var f1,f2:text;
a,b:array[1..100]of integer;
n,i:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
n:=0;
while not eof(f1) do
begin
n:=n+1;
readln(f1,a[n],b[n]);
end;
for i:=1 to n do
begin
if (a[i]<b[i]) then writeln(f2,a[i])
else writeln(f2,b[i]);
end;
close(f1);
close(f2);
end.
const fi='dl.dat';
fo='kq.dat';
var f1,f2:text;
a:array[1..100]of integer;
i,n,dem1,dem2,t1,t2: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]);
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then inc(dem1)
else inc(dem2);
end;
t1:=0;
t2:=0;
for i:=1 to n do
begin
if (a[i] mod 6=0) then t1:=t1+a[i];
if (a[i] mod 9=0) and (a[i] mod 2<>0) then t2:=t2+a[i];
end;
writeln(f2,dem1,' ',dem2);
writeln(f2,t1);
writeln(f2,t2);
close(f1);
close(f2);
end.
const fi='dl.dat';
fo='kq.dat';
var f1,f2:text;
a:array[1..100]of integer;
i,n,dem1,dem2,t1,t2: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]);
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then inc(dem1)
else inc(dem2);
end;
t1:=0;
t2:=0;
for i:=1 to n do
begin
if (a[i] mod 6=0) then t1:=t1+a[i];
if (a[i] mod 9=0) and (a[i] mod 2<>0) then t2:=t2+a[i]
end
writeln(f2,dem1,' ',dem2)
writeln(f2,t1)
writeln(f2,t2)
close(f1)
close(f2)
;-;
const fi='dl.pas';
fo='qk.pas';
var f1,f2:text;
i,n,dem,t,dem1,dem2,kt,j:integer;
a:array[1..100]of 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]);
dem:=0;
for i:=1 to n do
if (a[i] mod 2<>0) and (a[i] mod 7=0) then inc(dem);
t:=0;
for i:=1 to n do
if (10<=a[i]) and (a[i]<=30) then t:=t+a[i];
dem1:=0;
for i:=1 to n do
if (a[i]<0) and (a[i] mod 2<>0) then inc(dem1);
dem2:=0;
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 inc(dem2);
end;
writeln(f2,'So phan tu le chia het cho 7 la: ',dem);
writeln(f2,'Tong cac phan tu thuoc [10,30] la: ',t);
writeln(f2,'So cac phan tu am le la: ',dem1);
writeln(f2,'So phan tu la so nguyen to la: ',dem2);
close(f1);
close(f2);
end.
const fi='dulieu.inp';
fo='dulieu.out';
var f1,f2:text;
a:array[1..100]of integer;
n,i,dem:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
n:=0;
while not eof(f1) do
begin
n:=n+1;
readln(f1,a[n]);
end;
dem:=0;
for i:=1 to n do
if a[i] mod 2=0 then inc(dem);
writeln(f2,dem);
close(f1);
close(f2);
end.
program BaiToanMang;
var
A: array[1..100] of integer;
N, i, demChan, tongLeChia3: integer;
begin
write('Nhap so phan tu cua mang: ');
readln(N);
writeln('Nhap cac phan tu cua mang: ');
for i := 1 to N do
begin
write('a[', i, ']= ');
readln(A[i]);
end;
tongLeChia3 := 0;
for i := 1 to N do
begin
if (A[i] mod 2 = 1) and (A[i] mod 3 = 0) then
begin
tongLeChia3 := tongLeChia3 + A[i];
end;
end;
writeln('Tong cac so le chia het cho 3: ', tongLeChia3);
demChan := 0;
for i := 2 to N do
begin
if (A[i] mod 2 = 0) and (i mod 2 = 1) then
begin
demChan := demChan + 1;
end;
end;
writeln('So phan tu chan o vi tri le: ', demChan);
writeln('Cac so chan chia het cho 5: ');
for i := 1 to N do
begin
if (A[i] mod 2 = 0) and (A[i] mod 5 = 0) then
begin
write(A[i], ' ');
end;
end;
end.
ko bt đúng ko ko dùng pascal nhiều
#include <bits/stdc++.h>
using namespace std;
long long a[15],n,i,dem;
int main()
{
freopen("songuyen.inp","r",stdin);
freopen("ketqua.out","w",stdout);
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
dem=0;
for (i=1; i<=n; i++)
if (a[i]%3==0) dem++;
cout<<dem;
return 0;
}
có thể giúp mình làm kiểu pascal đc ko bn