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.

21 tháng 8 2019

Đợi chút mình đang giải.

21 tháng 8 2019

Đúng rồi , bạn thêm:

const fi='bai3.inp';

fo='bai3.out';

22 tháng 8 2019

Lời giải:

Nhập mảng phải có nhập số lượng phần tử nữa bạn nhé.

program hotrotinhoc;

const fi='bai5.inp';

fo='bai5.out';

var f: text;

i,j,n,max,max1,max2,max3,max4: longint;

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

function dn(x: integer): integer;

var s: integer;

begin

s:=0; dn:=0;

while x<>0 do

begin

s:=s*10+(x mod 10);

x:=x div 10;

end;

dn:=s;

end;

function nt(x1: integer): boolean;

var j: integer;

begin

nt:=false;

if x1<2 then exit;

for j:=2 to trunc(sqrt(x1)) do

if x1 mod j=0 then exit;

nt:=true;

end;

function tongcs(x2: integer): integer;

var s1: integer;

begin

s1:=0;

while x2<>0 do

begin

s1:=s1+(x2 mod 10);

x2:=x2 div 10;

end;

tongcs:=s1;

end;

function ucln(x3,y: integer) : integer;

var z: integer;

begin

while y<>0 do

begin

z:=x3 mod y;

x3:=y;

y:=z;

end;

ucln:=x3;

end;

procedure ip;

begin

assign(f,fi);

reset(f);

readln(f,n);

for i:=1 to n do

read(f,a[i]);

close(f);

end;

procedure out;

begin

assign(f,fo);

rewrite(f);

max:=0; max2:=0; max3:=0;

for i:=1 to n do

begin

if (dn(a[i])=a[i]) and (a[i]>max) then max:=a[i];

if dn(a[i])>max2 then max2:=dn(a[i]);

if (nt(a[i])) and (tongcs(a[i])>max3) then max3:=a[i];

end;

writeln(f,max);

for i:=1 to n do if dn(a[i])=max2 then

writeln(f,a[i]);

max4:=0;

for i:=1 to n do

for j:=i to n do

if (a[i]<>a[j]) and (ucln(a[i],a[j])>max4) then max4:=ucln(a[i],a[j]);

for i:=1 to n do

for j:=i to n do

if ucln(a[i],a[j])=max4 then writeln(f,a[i],' ',a[j]);

write(f,max3);

close(f);

end;

begin

ip;

out;

end.

22 tháng 8 2019

camr ơn

29 tháng 7 2021

uses crt;

var f,g:text;

n,i,m,k,j:integer;

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

const fi='BAI2.INP'; fo='BAI2.OUT';

begin

assign(f,fi); reset(f);

assign(g,fo); rewrite(g);

readln(f,n);

for i:=1 to n do

readln(f,a[i]);

for i:=1 to n do

begin

m:=a[i];

for j:=i+1 to n do

if odd(m+a[j])=false then k:=k+1;

end;

write(g,k);

close(f);

close(g);

end.

 

 

15 tháng 5 2023

Program HOC24;

var i,n: integer;

t: longint;

f1,f2: text;

begin

assign(f1,'BAI1.INP');

reset(f1);

read(f1,n);

t:=0;

for i:=1 to n do if i mod 2=0 then t:=t+i;

close(f1);

assign(f2,'BAI1.OUT');

rewrite(f2);

write(f2,t);

close(f2);

end.

24 tháng 3 2023

Program HOC24;

var n: longint;

d,max: byte;

begin

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

max:=0;

while n<>0 do

begin

d:=n mod 10;

if d>max then max:=d;

n:=n div 10;

end;

write('Chu so lon nhat la: ',max);

readln

end.

6 tháng 4 2017

uses crt;
const finp='Bai1.inp';
fout='Bai1.out';
type mangc=array[1..10000] of char;
mangl=array[1..10000] of longint;
var f:text;
ch:mangc; a:mangl;
n:longint;
procedure doc;
var i:longint;
begin
assign(f,finp);
reset(f);
readln(f,n);
for i:=1 to n do read(f,ch[i]);
close(f);
end;
procedure ghi;
begin
assign(f,fout);
rewrite(f);
end;
procedure tim;
var i,j,d,k,l:longint;
begin
for i:=n-2 downto 1 do
begin
a[i]:=1;
d:=0;
for j:=i+1 to n do
begin
l:=a[j];
if ch[i]=ch[j] then a[j]:=d+2
else if a[j-1]>a[j] then a[j]:=a[j-1];
d:=l;
end;
end;
end;
procedure xuly;
var i:longint;
begin
fillchar(a,sizeof(a),0);
if n=1 then a[n]:=1
else begin
a[n-1]:=1;
a[n]:=ord(ch[n]=ch[n-1])+1;
end;
if n>2 then tim;
write(f,n-a[n]);
end;
begin
doc;
ghi;
xuly;
close(f);
end.

ai có thể giải thích cho mình bài này đc không

nhất là cái "procedure tim" và mục đích của mảng số nguyên a

mk cảm ơn nhiều

13 tháng 12 2023

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> mp;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    freopen("MAP1.INP","r",stdin);
    freopen("MAP1.OUT","w",stdout);
    ll n; cin >> n;
    ll a[n+5];
    for(ll i=1;i<=n;i++) cin >> a[i], mp[a[i]]++;
    for(pair<ll,ll> it:mp) cout << it.first << " " << it.second << "\n";
}

Chúc bạn học tốt!