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 hotrotinhoc;
var d,toa1,toa2,toa3,toa4,toa5,toa6,toa7 : byte;
tb: real;
begin
toa1:=7; toa2:=17; toa3:=11; toa4:=7; toa5:=9; toa6:=7;
tb:=(toa1+toa2+toa3+toa4+toa5+toa6)/6;
writeln('So hanh khach trung binh cua doan tau nay la:',tb:2:0);
if toa1>tb then inc(d);
if toa2>tb then inc(d);
if toa3>tb then inc(d);
if toa4>tb then inc(d);
if toa5>tb then inc(d);
if toa6>tb then inc(d);
write('Co ',d,'toa co so luong hanh khach lon hon so luong hanh khach trung binh cua doan tau');
readln
end.
#include <bits/stdc++.h>
using namespace std;
long long i,n,k,dem,x;
int main()
{
cin>>n>>k;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x==k) dem++;
}
cout<<dem;
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,dem:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
dem:=0;
for i:=1 to n do
if trunc(sqrt(a[i]))=sqrt(a[i]) then inc(dem);
writeln(dem);
readln;
end.
Câu 1:
program mangsonguyen;
var
a: array[1..100] of integer;
i, n: integer;
begin
writeln('Nhap so phan tu trong mang: ');
readln(n);
writeln('Nhap cac phan tu cua mang: ');
for i := 1 to n do
readln(a[i]);
writeln('Mang vua nhap la:');
for i := 1 to n do
write(a[i], ' ');
end.
Câu 2:
program trungbinhcong;
var
a: array[1..100] of integer;
i, n, k, sum: integer;
avg: real;
begin
writeln('Nhap so phan tu trong mang: ');
readln(n);
writeln('Nhap cac phan tu cua mang: ');
for i := 1 to n do
readln(a[i]);
writeln('Nhap so k: ');
readln(k);
sum := 0;
for i := 1 to n do
begin
if a[i] <= k then
sum := sum + a[i];
end;
if sum > 0 then
begin
avg := sum / n;
writeln('Trung binh cong cac phan tu co gia tri <= ', k, ' la: ', avg:0:2);
end
else
begin
writeln('Khong co phan tu nao co gia tri <= ', k);
end;
end.
Câu 3:
program DemSoNguyenTo;
var
a: array [1..100] of integer;
i, j, n, count: integer;
laSoNguyenTo: boolean;
begin
write('Nhap so phan tu cua mang: ');
readln(n);
write('Nhap cac phan tu cua mang: ');
for i := 1 to n do
readln(a[i]);
count := 0;
writeln('Cac so nguyen to trong mang la: ');
for i := 1 to n do
begin
laSoNguyenTo := true;
for j := 2 to (a[i] div 2) do
begin
if (a[i] mod j = 0) then
begin
laSoNguyenTo := false;
break;
end;
end;
if laSoNguyenTo and (a[i] > 1) then
begin
writeln(a[i]);
count := count + 1;
end;
end;
writeln('Tong so cac so nguyen to la: ', count);
readln;
end.
program bai_tap;
uses crt;
var a,b,c,d,e,f,g,s,dem :byte;
tb:real;
begin
clrscr;
{cau a}
write('nhap lan luot so hanh khach moi toa: ');
readln(a,b,c,d,e,f,g);
{cau b}
s:=a+b+c+d+e+f+g;
writeln('tong so hanh khach la: ',s);
{cau c}
tb:=s / 7;
dem:=0;
if (a < tb) then inc(dem);
if (b < tb) then inc(dem);
if (c < tb) then inc(dem);
if (d < tb) then inc(dem);
if (e < tb) then inc(dem);
if (f < tb) then inc(dem);
if (g < tb) then inc(dem);
writeln('co ',dem,' toa co hanh khach it hon so luong hanh khach tb');
readln;
end.