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 HOC24;
const fi='Data.txt';
fo='Result.txt';
var f: text;
a,b: integer;
dt,cv: longint;
dc: real;
procedure ip;
begin
assign(f,fi);
reset(f);
readln(f,a);
readln(f,b);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
dt:=a*b;
cv:=(a+b)*2;
dc:=sqrt((a*a)+(b*b));
writeln(f,'Chu vi hinh chu nhat la : ',cv);
writeln(f,'Dien tich cua hinh chu nhat la : ',dt);
write(f,'Chieu dai cua duong cheo la : ',dc:1:2);
close(f);
end;
begin
ip;
out;
end.
uses crt;
const fi='dl.txt';
var f1:text;
a,b,c,kq:integer;
{---------------------------chuong-trinh-con-doc-tep------------------------}
procedure docfile;
begin
assign(f1,fi); reset(f1);
readln(f1,a,b,c);
end;
{---------------------------chuong-trinh-con-tim-gtln-----------------------}
function gtln(n,m:integer):integer;
begin
gtln:=n;
if gtln<m then gtln:=m;
end;
{---------------------------chuong-trinh-chinh------------------------------}
begin
clrscr;
docfile;
kq:=gtln(a,b);
if kq<c then kq:=c;
writeln(kq);
close(f1);
readln;
end.
uses crt;
var a,b,c,d:array[1..100]of integer;
n,i,dem,t,max,min,j,dem1,kt,dem2,dem3,kt1:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Phan tu dau tien la: ',a[1]);
writeln('Phan tu cuoi cung la: ',a[n]);
dem:=0;
for i:=1 to n do
if a[i] mod 4=0 then inc(dem);
writeln('So luong phan tu chia het cho 4 la: ',dem);
t:=0;
for i:=1 to n do
if (a[i] mod 2=0) and (a[i]>10) then t:=t+a[i];
writeln('Tong cac so chan va lon hon 10 la: ',t);
dem1:=0;
for i:=1 to n do
if sqrt(a[i])=trunc(sqrt(a[i])) then
begin
inc(dem1);
b[dem1]:=a[i];
end;
writeln;
writeln('So luong so chinh phuong trong mang la: ',dem1);
if dem1>0 then
begin
writeln('Cac so chinh phuong co trong mang la: ');
for i:=1 to dem1 do
write(b[dem1]:4);
end;
writeln;
kt:=0;
for i:=1 to n do
if a[i] mod 2<>0 then kt:=1;
if kt=0 then writeln('Day la mang chan')
else writeln('Day khong la mang chan');
readln;
end.
uses crt;
var a:array[1..100]of integer;
n,i,t,dem,max,min,kt,j,x,dem1,k:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cac phan tu cua mang la: ',t);
dem:=0;
for i:=1 to n do
if a[i]<0 then inc(dem);
writeln('So phan tu am co trong mang la: ',dem);
max:=a[1];
min:=a[1];
for i:=1 to n do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('Tong phan tu nho nhat va lon nhat trong mang la: ',max+min);
writeln('Vi tri cac so nguyen to co trong mang 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(i:4);
end;
writeln;
repeat
write('Nhap x='); readln(x);
until x>0;
dem1:=0;
for i:=1 to n do
if a[i]>0 then inc(dem1);
if dem1<x then writeln(x,' nho hon so luong so nguyen duong trong mang')
else if dem1=x then writeln(x,' la so luong so nguyen duong trong mang')
else writeln(x,' lon hon so luong so nguyen duong trong mang');
readln;
end.
#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;
}
#include <bits/stdc++.h>
using namespace std;
long long n,i,a[1000];
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
sort(a+1,a+n+1);
for (i=n; i>=1; i--) cout<<a[i]<<" ";
return 0;
}
Bài 1:
uses crt;
var a,b:array[1..100]of integer;
i,n,dem,t,dem1,max,tam,j,kt:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
for i:=1 to n do
if a[i] mod 2<>0 then inc(dem);
writeln('So luong so le la: ',dem);
t:=0;
for i:=1 to n do
if a[i] mod 5=0 then t:=t+a[i];
writeln('Tong cac phan tu chia het cho 5 la: ',t);
dem1:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
inc(dem1);
b[dem1]:=a[i];
end;
max:=b[1];
for i:=1 to dem1 do
if max<b[i] then max:=b[i];
writeln('Phan tu chan lon nhat la: ',max);
writeln('Vi tri cua no trong mang la: ');
for i:=1 to n do
if max=a[i] then write(i:4);
writeln;
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;
writeln('Mang duoc sap xep tang dan la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
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;
readln;
end.
Bài 3:
Program HOC24;
const fi='Nhapvao.txt';
var f: text;
begin
assign(f,fi);
reset(f);
close(f);
end.
Bài 2:
Program HOC24;
const fo='CaDao.txt';
var f: text;
begin
assign(f,fo);
rewrite(f);
writeln(f,'Cong cha nhu nui thai son');
writeln(f,'Nghia me nhu nuoc trong nguon chay ra.');
writeln(f,'Mot long tho me kinh cha');
write(f,'Cho tron chu hieu moi la dao con');
close(f);
end.