Bạn chưa đăng nhập. Vui lòng đăng nhập để hỏi bài

Những câu hỏi liên quan
lê chí hiếu
Xem chi tiết
Minh Lệ
21 tháng 8 2019 lúc 21:11

Bài 4 rất hay, lúc nào có lời giải mình sẽ gửi cho bạn.

Minh Lệ
21 tháng 8 2019 lúc 20:14

Lời giải :

Đề thiếu ở INP là nhập số lượng phần tử

Bài 1:

program hotrotinhoc;

const fi='bai1.inp';

fo='bai1.out';

var i,n : integer;

f: text;

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

function dn(x: integer): integer;

var s: integer;

begin

dn:=0; s:=0;

while x>0 do

begin

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

x:= x div 10;

end;

dn:=s;

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);

for i:=1 to n do

if dn(a[i])=a[i] then write(f,a[i],' ');

close(f);

end;

begin

ip;

out;

end.

Minh Lệ
21 tháng 8 2019 lúc 20:31

Lời giải:

Bài 2:

program hotrotinhoc;

const fi='bai2.inp';

fo='bai2.out';

var f: text;

i,n: integer;

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

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

var s: integer;

begin

while y<>0 do

begin

s:= x mod y;

x:=y;

y:=s;

end;

ucln:=x;

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);

for i:=2 to n do

write(f,ucln(a[1],a[i]),' ');

close(f);

end;

begin

ip;

out;

end.

Khánh Linh
Xem chi tiết
Nguyễn Lê Phước Thịnh
26 tháng 2 2022 lúc 22:53

Bài 2: 

#include <bits/stdc++.h>

using namespace std;

long long a[1000],i,n,ln,nn;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

for (i=1; i<=n; i++) cout<<a[i]<<"     ";

cout<<endl;

ln=a[1];

nn=a[1];

for (i=2; i<=n; i++)

{

ln=max(ln,a[i]);

nn=min(nn,a[i]);

}

cout<<ln<<" "<<nn;

}

lê chí hiếu
Xem chi tiết
Minh Lệ
22 tháng 8 2019 lúc 11:04

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.

ngomanhcuong
Xem chi tiết
Nguyễn Lê Phước Thịnh
15 tháng 3 2022 lúc 20:25

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,t,dem;

int main()

{

cin>>n;

dem=0;

t=0;

for (i=1; i<=n; i++)

{

cin>>x;

if (x%2==0 && x>10) t+=x;

if (x%2!=0 || x<100) dem++;

}

cout<<t<<" "<<dem;

return 0;

}

Nguyễn Kim Trí
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 1 2022 lúc 20:24

#include <bits/stdc++.h>

using namespace std;

double a[1000];

int n,i;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

for (i=1; i<=n; i++) cout<<a[i]<<" ";

return 0;

}

Kiều Vũ Linh
22 tháng 1 2022 lúc 8:03

Var a:array[1..100] of real;

n,i:integer;

Begin

Write('Nhap so luong so n = ');readln(n);

For i:=1 to n do

Begin

Write('Nhap so thu ',i);readln(a[i]);

End;

Writeln('Cac so vua nhap la:');

For i:=1 to n do

Begin

Write(a[i]:10:2,'   ');

Readln;

End.

Tran Trang
Xem chi tiết
HT.Phong (9A5)
20 tháng 4 2023 lúc 12:25

Uses crt;

var n,i,max,min: integer;

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

begin clrscr;

readln(n);

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

max:=a[1];

for i:=1 to n do if(max<a[i]) then max:=a[i];

writeln(max);

min:=a[1];

for i:=1 to n do if(min>a[i]) then min:=a[i];

writeln(min);

readln;

end.

Khánh Linh
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 2 2022 lúc 20:07

uses crt;

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

i,n,t,j,tam:integer;

begin

clrscr;

readln(n);

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

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

writeln;

writeln('Cac so duong la: ');

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

writeln;

t:=0;

for i:=1 to n do 

  if a[i] mod 3=0 then t:=t+a[i];

writeln(t);

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(a[i]:4);

readln;

end.

Thọ Lê Đức
Xem chi tiết
Kiều Vũ Linh
28 tháng 4 2023 lúc 16:09

Bài 23

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

i,n:integer;

s,tbc:real;

begin

write('n = ');readln(n);

for i:=1 to n do

begin

write('Nhap so thu ',i,' = ');readln(a[i]);

s:=s+a[i];

end;

tbc:=s/n;

writeln('Gia tri trung binh la ',tbc:10:2);

write('Cac so lon hon gia tri trung binh la: ');

for i:=1 to n do

if a[i] > tbc then write(a[i]:8);

readln

end.

Kiều Vũ Linh
28 tháng 4 2023 lúc 16:12

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

i,n,max:integer;

begin

write('n = ');readln(n);

for i:=1 to n do

begin

write('Nhap so thu ',i,' = ');readln(a[i]);

end;

max:=a[1];

for i:=2 to n do

if a[i] > max then max:=a[i];

for i:=1 to n do

begin

if max=a[i] then write(max,' o vi tri thu ',i);

break;

readln

end.

Lê Thùy Ánh
Xem chi tiết
KhảTâm
14 tháng 5 2021 lúc 16:20

Bài 1:program sothuc;

uses crt;

var a:array[1..10] of real;s,i,j:real;

begin

s:=0;

for i:=1 to 10 do begin writeln('A[',i,']=');readln(a[i]); end;

for i:=1 to 10 do if a[i]<0 then

for j:=1 to 10 do

begin a[j]:=sqr(a[i]); s:=s+a[j]; end;

writeln('tong binh phuong cac so am la: ',s:2:2); readln;

end. (Khi nào mình kiểm tra chạy lại trên phần mềm rồi sửa lại nếu sai nhé)

Bài 2: 

program soduong;

uses crt;

var a:array[1..100] of integer;s,i,n:integer;

begin

clrscr;

writeln('nhap do dai cua day');readln(n);

for i:=1 to n do begin

writeln('a[',i,']=');readln(a[i]);

if a[i] mod 2 = 0 then s:=s+a[i] end;

writeln('tong so duong trong day la',s:2:0);readln

end.

Bài 3: các số dương mà là số lẻ là sao thế bạn????

Khách vãng lai đã xóa