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.

câu 1:
Program So_hoan_hao;
uses crt;
Var S, n, i,j: integer;
Begin
clrscr;
Write('Nhap so n ='); readln(n);
For i:=1 to n do
Begin
S:=0;
For j:=1 to i do
if i mod j = 0 then
S:=S+j;
if S = 2*i then
write(,' la so hoan chinh');
end;
readln;
end.
*Số kg nhập từ bàn phím nha
mình không biết đâu làm bừa thôi

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
struct Person {
int index; // Vị trí của người trong hàng
int time; // Thời gian mua vé của người
};
bool compareByTime(const Person& a, const Person& b) {
return a.time < b.time;
}
int main() {
// Đọc dữ liệu từ tệp TICKET.INP
std::ifstream inputFile("TICKET.INP");
if (!inputFile.is_open()) {
std::cerr << "Khong the mo tep TICKET.INP" << std::endl;
return 1;
}
int n;
inputFile >> n;
std::vector<Person> people;
for (int i = 1; i <= n; ++i) {
Person person;
person.index = i;
inputFile >> person.time;
people.push_back(person);
}
// Đóng tệp TICKET.INP
inputFile.close();
// Sắp xếp danh sách người theo thời gian mua vé tăng dần
std::sort(people.begin(), people.end(), compareByTime);
// Tìm người mua vé cặp để tổng thời gian bán vé là ít nhất
int totalTime = 0;
int minTotalTime = INT_MAX;
int bestPairIndex = -1;
for (int i = 0; i < n - 1; ++i) {
totalTime += people[i].time;
if (totalTime + people[i + 1].time < minTotalTime) {
minTotalTime = totalTime + people[i + 1].time;
bestPairIndex = i;
}
}
// Ghi kết quả ra màn hình
std::cout << "Nguyen vien ban ve can ban ve cap cho nguoi thu: " << people[bestPairIndex + 1].index << std::endl;
return 0;
}

Câu 1:
uses crt;
var a,b:integer;
begin
clrscr;
readln(a,b);
writeln((a+b)/2:4:2);
readln;
end.

program GiamGiaTheoSoLuong;
varsoluonghoa: integer;
dongia, thanhtien: real;
begin
write('Nhap so luong hoa: ');
readln(soluonghoa);
write('Nhap don gia: ');
readln(dongia);
thanhtien := soluonghoa * dongia;
if soluonghoa >= 10 then
thanhtien := thanhtien * 0.9
else if soluonghoa >= 5 then
thanhtien := thanhtien * 0.95;
writeln('So luong hoa: ', soluonghoa);
writeln('Don gia: ', dongia:0:2);
writeln('Thanh tien: ', thanhtien:0:2);
readln;
end.

program sach_cua_hieu;
const
MAX_LOAI_SACH = 1000;
MIN_SO_LUONG = 1;
var
loai_sach: array[1..MAX_LOAI_SACH] of integer;
so_luong: array[1..MAX_LOAI_SACH] of integer;
n: integer;
i, max_so_luong, loai_sach_nhieu_nhat: integer;
begin
write('Nhập số loại sách: ');
readln(n);
for i := 1 to n do
begin
write('Nhập số lượng sách của loại ', i, ': ');
readln(so_luong[i]);
loai_sach[i] := i;
end;
max_so_luong := MIN_SO_LUONG;
loai_sach_nhieu_nhat := 1;
for i := 1 to n do
begin
if so_luong[i] > max_so_luong then
begin
max_so_luong := so_luong[i];
loai_sach_nhieu_nhat := i;
end;
end;
writeln('Loại sách còn nhiều nhất là loại ', loai_sach[loai_sach_nhieu_nhat]);
writeln('Số lượng còn lại là ', max_so_luong);
end.

program Psmcg;
uses crt;
var don_gia, so_luong, tong_tien, phi_giao_hang: integer;
begin
write('Nhap so luong san pham: ');
readln(so_luong);
if so_luong <= 20 then
begin
don_gia := 50000;
end
else
begin
don_gia := 40000;
end;
tong_tien := don_gia * so_luong;
if tong_tien > 2000000 then
begin
phi_giao_hang := 0;
end
else
begin
phi_giao_hang := 15000;
end;
tong_tien := tong_tien + phi_giao_hang;
writeln('So tien khach hang phai thanh toan la: ', tong_tien);
readln;
end.
Var t16,17,t21:Integer;
Begin
For t16:=0 to 11 do
For t17:=0 to 10 do
For 121:=0 to 8 do
If t16*1+t18*18+t21*21=185 then
Writeln(t16:5,t17:8,t21:10);
Readln;
End.
à thầy bạn dùng câu lênh for ...to lồng.