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.
uses crt;
var a:array[1..100]of integer;
i,n,t,dem,kt,j:integer;
tbc:real;
begin
clrscr;
write('n='); readln(n);
if (1<=n) and (n<=100) then
begin
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{----------------------cau-a----------------------}
dem:=0;
t:=0;
for i:=1 to n do
if a[i]>0 then
begin
inc(dem);
t:=t+a[i];
end;
tbc:=t/dem;
writeln('trung binh cong cua cac phan tu lon hon 0 trong day so la: ',tbc:4:2);
{---------------------cau-b-----------------------}
writeln('cac so nguyen to co 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;
end
else writeln('vui long nhap lai so n');
readln;
end.
program crtg;
uses crt;
var n,i, j: integer;
A: array[1..1000] of byte;
tb: integer;
min,max: byte;
begin
clrscr;
writeln('Nhap do dai day A: '); read(n);
writeln('Nhap cac phan tu cua day: ');
for i:=1 to n do
begin
writeln('a[',i,'] = ');
repeat
read(a[i]);
until a < 100;
end;
for i:= 1 to n do
begin
if a[i] <> 1 then
begin
j:= 2;
while (a[i] mod j <> 0) do j:=j+1;
if j = a[i] then write(a[i]',');
end;
end;
tb:=0;
for i:=1 to n do
tb:=tb+a[i];
tb:=tb/n;
writeln('Gia tri trung binh cua day tren la: ',tb);
max:=a[1]; min:=a[1];
for i:=2 to n do
begin
if a[i] < min then min:=a[i];
if a[i] > max then max:=a[i];
end;
writeln('Gia tri lon nhat cua day la ',max);
writeln('Gia tri nho nhat cua day la ',min);
readln
end.
2:
#include <bits/stdc++.h>
using namespace std;
int A[100],ln,nn,vt1,vt2,n;
int main()
{
cin>>n;
for(int i=1; i<=n; i++) cin>>A[i];
ln=A[1];
for (int i=1; i<=n; i++)
ln=max(ln,A[i]);
nn=A[1];
for (int i=1; i<=n; i++)
nn=min(nn,A[i]);
vt1=1; vt2=n;
for (int i=1; i<=n; i++)
if (ln==A[i] && vt1<=i) vt1=i;
for (int i=n; i>=1; i--)
if (nn==A[i] && vt2>=i) vt2=i;
swap(A[vt1],A[vt2]);
for (int i=1; i<=n; i++)
cout<<A[i]<<" ";
}
uses crt;
var a,b:integer;
begin
clrscr;
write('a='); readln(a);
write('b='); readln(b);
if b=0 then writeln('khong co phep chia cho 0')
else writeln('thuong cua phep chia ',a,' cho ',b,' la: ',a/b:4:2);
readln;
end.
program ho_tro;
uses crt;
var a,b,c: real;
begin
clrscr;
writeln(' nhap a va b:'); readln(a,b);
if b<>0 then c:=a/b
else writeln(' loi yeu cau nhap lai:');
writeln(' ket qua cua a chia b la:',c);
readln;
end.
```cpp
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
for (int a = 0; a <= n; a++) { int b = n - a; if (b >= 0 && b <= INT_MAX) { cout << a << " " << b << endl; } } return 0;
}
```
#include <iostream>
int main() {
int n;
std::cout << "Nhap so tu nhien n (0 <= n <= 100): ";
std::cin >> n;
int a, b;
// Chia n thành hai phần bằng nhau
a = n / 2;
b = n - a;
std::cout << "Hai so nguyen a va b thoa man a + b = " << n << " la: " << a << " " << b << std::endl;
return 0;
}