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.
Program day_nghich_the;
uses crt;
const fn = 'nghich.inp';
gn = 'nghich.out';
nmax=10000;
var f,g:text;
n,i,j,dem:0..nmax;
a,b,luu:array[1..nmax] of 0..nmax;
procedure nhap;
begin fillchar(a,sizeof(a),0);
b:=a;
assign(f,fn);
reset(f);
readln(f,n);
for i:=1 to n do read(f,a[i]);
write(f);
for i:=1 to n do read(f,b[i]);
close(f);
end;
procedure tim_b;
begin
fillchar(luu,sizeof(luu),0);
for i:=1 to n do
begin
dem:=0;
for j:=i -1 downto 1 do
if a[i]<a[j] then inc(dem);
luu[a[i]]:=dem;
end;
for i:=1 to n do write(g,luu[i]:2);
writeln(g); writeln(g);
end;
procedure tim_a;
begin
fillchar(luu,sizeof(luu),0);
for i:=1 to n do
if b[i]>n-i then exit else
begin
j:=0;
dem:=0;
repeat inc(dem);
if luu[dem]=0 then j:=j+1;
until j>b[i];
luu[dem]:=i;
end;
for i:=1 to n do
write(g,luu[i]:2);
end;
BEGIN
nhap;
assign(g,gn);
rewrite(g);
tim_b;
tim_a;
close(g);
END.
Program HOC24;
var i,n: integer;
a: array[1..1000] of integer;
t: longint;
f1,f2: text;
const fi='DATA1.TXT';
fo='KQ1.TXT';
begin
assign(f1,fi);
assign(f2,fo);
reset(f1);
rewrite(f2);
readln(f1,n);
for i:=1 to n do read(f1,a[i]);
t:=0;
for i:=1 to n do if a[i] mod 2=0 then t:=t+a[i];
writeln(f2,t);
for i:=1 to n do if a[i] mod 5=0 then write(f2,a[i],' ');
close(f1); close(f2);
end.
program du_lieu;
uses crt;
var i,n:integer;
a:array[1..100]of integer;
tbc:real;
f:text;
begin
clrscr;
assign(f,'DULIEU.INP');reset(f);
readln(f,n);
for i:=1 to n do
begin
read(f,a[i]);
end;
close(f);
for i:=1 to n do
tbc:=tbc+a[i];
writeln(tbc/n);
readln;
end.
uses crt;
const fi='dulieu.inp';
var f1:text;
a:array[1..100]of integer;
n,i,t1,t2:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
readln(f1,n);
for i:=1 to n do
read(f1,a[i]);
t1:=0;
t2:=0;
for i:=1 to n do
begin
if a[i]>0 then t1:=t1+a[i];
if a[i]<0 then t2:=t2+a[i];
end;
writeln('Tong cac so duong la: ',t1);
writeln('Tong cac so am la: ',t2);
close(f1);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i;
int main()
{
freopen("so.inp","r",stdin);
freopen("so.out","w",stdout);
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]%2==0) cout<<a[i]<<" ";
return 0;
}