Viết ct nhập n số nguyên dương, n < = 10000 các số trong phạm vị từ 0 đến 254. Tìm top 30 giá trị số có số lần xuất hiện nhiều hơn cả. Mong anh chị giải giúp e với ạ
Viết ct nhập n số nguyên dương, n < = 10000 các số trong phạm vị từ 0 đến 254. Tìm top 30 giá trị số có số lần xuất hiện nhiều hơn cả. Mong anh chị giải giúp e với ạ
Cho S = a/b + c/d ( a,b,c,d nhập từ bàn phím ) lập trình tính tổng S trên
uses crt;
var a,b,c,d:integer;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
write('Nhap c='); readln(c);
write('Nhap d='); readln(d);
if (b<>0) and (d<>0) then writeln(a/b+c/d:4:2)
else writeln('Vui long nhap lai');
readln;
end.
Bài 2:
uses crt;
var a,b,c,p,s,am,bn,cp:real;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
write('Nhap c='); readln(c);
if (a>0) and (b>0) and (c>0) and (a+b>c) and (a+c>b) and (b+c>a) then
begin
writeln('Day la ba canh trong mot tam giac vuong');
p:=(a+b+c)/2;
s:=sqrt(p*(p-a)*(p-b)*(p-c));
writeln('Dien tich tam giac la: ',s:4:2);
am:=sqrt(2*(sqr(b)+sqr(c))-sqr(a))/4;
bn:=sqrt(2*(sqr(a)+sqr(c))-sqr(b))/4;
cp:=sqrt(2*(sqr(a)+sqr(b))-sqr(c))/4;
writeln('Do dai duong trung tuyen ung voi canh a la: ',am:4:2);
writeln('Do dai duong trung tuyen ung voi canh b la: ',bn:4:2);
writeln('Do dai duong trung tuyen ung voi canh c la: ',cp:4:2);
end
else writeln('Day khong la ba canh trong mot tam giac');
readln;
end.
Bài 3:
uses crt;
var a,b,ucln,bcnn,i:integer;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
ucln:=1;
if a<b then
begin
for i:=1 to a do
if (a mod i=0) and (b mod i=0) then
begin
if ucln<i then ucln:=i;
end;
end
else begin
for i:=1 to b do
if (a mod i=0) and (b mod i=0) then
begin
if ucln<i then ucln:=i;
end;
end;
writeln('Uoc chung lon nhat la: ',ucln);
bcnn:=a*b;
for i:=a*b-1 downto 1 do
if (i mod a=0) and (i mod b=0) then
begin
if bcnn>i then bcnn:=i;
end;
writeln('Boi chung nho nhat la: ',bcnn);
readln;
end.
Bài 2:
uses crt;
var a,b,c,p,s,am,bn,cp:real;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
write('Nhap c='); readln(c);
if (a>0) and (b>0) and (c>0) and (a+b>c) and (a+c>b) and (b+c>a) then
begin
writeln('Day la ba canh trong mot tam giac vuong');
p:=(a+b+c)/2;
s:=sqrt(p*(p-a)*(p-b)*(p-c));
writeln('Dien tich tam giac la: ',s:4:2);
am:=sqrt(2*(sqr(b)+sqr(c))-sqr(a))/4;
bn:=sqrt(2*(sqr(a)+sqr(c))-sqr(b))/4;
cp:=sqrt(2*(sqr(a)+sqr(b))-sqr(c))/4;
writeln('Do dai duong trung tuyen ung voi canh a la: ',am:4:2);
writeln('Do dai duong trung tuyen ung voi canh b la: ',bn:4:2);
writeln('Do dai duong trung tuyen ung voi canh c la: ',cp:4:2);
end
else writeln('Day khong la ba canh trong mot tam giac');
readln;
học tốt nha b
Mọi người giúp e chỉnh lại pt với ghi thêm mấy cái Pt kia giúp e với cảm ơn nhiều ạ
def ptb2 () :
from math import sqrt
print('nhap a,b,c khac 0:')
a,b,c=map(float,input().split())
d=b**2-4*a*c
if d<0:
print('phuong trinh vo nghiem')
elif d==0:
print('phuong trinh co nghiem',-b/2*a)
else:
x1=(-b-sprt(d))/(2*a)
x2=-b/a-x1
print('x1=',x1)
print('x2=',x2)
def dthcn ():
a,b=map(float,input('nhap ab,cr la :').split())
S=a*b
print('dien tich la :',S)
while True:
print('bat dau')
print('Bang chon viec')
print('1.giaiptb2')
print('2.dthcn')
print('3.gptb1')
print('4.dtht')
print('5.dthtg')
print('6.dtht')
print('7.thoat khoi chuong trinh')
print('ket thuc')
chon=input('hay chon(1,2,3,4,6,7):')
if chon == '1':
print('gptb2')
ptb2()
elif chon == '2':
print('dthcn')
dthcn()
else:
print('tam biet')
break