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.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,x;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
sort(a+1,a+n+1);
for (i=1; i<=n; i++)
{
int x=sqrt(a[i]);
if (x*x==a[i])
{
cout<<x;
return 0;
}
}
cout<<"Ko co so chinh phuong trong day";
return 0;
}
uses crt;
var x,i,max,n,dem,dem1,dem2,dem3,t,t1:integer;
a,b,c,d,e:array[-32000..32000]of integer;
tbca,tbcd:real;
begin
clrscr;
write(‘n=’); readln(n);
for i:=1 to n do
begin
write(‘a[‘,i,’]=’); readln(a[i]);
inc(b[a[i]]);
end;
{———————————-cau-a—————————-}
max:=0;
for i:=1 to n do
if max<b[a[i]] then
begin
max:=b[a[i]];
x:=a[i];
end;
writeln(‘phan tu co so lan xuat hien nhieu nhat trong mang la: ‘,x);
{——————————–cau-b——————————-}
dem:=0;
for i:=1 to n do
if a[i]>=0 then
begin
dem:=dem+1;
c[dem]:=a[i];
end;
dem1:=0;
for i:=1 to dem do
if trunc(sqrt(c[i]))=sqrt(c[i]) then inc(dem1);
writeln(‘so luong so chinh phuong trong day la: ‘,dem1);
{——————————–cau-c—————————–}
dem2:=0;
dem3:=0;
for i:=1 to n do
begin
if a[i]>0 then
begin
inc(dem2);
d[dem2]:=a[i];
end;
if a[i]<0 then
begin
inc(dem3);
e[dem3]:=a[i];
end;
end;
t:=0;
t1:=0;
for i:=1 to dem2 do
t:=t+d[i];
tbcd:=t/dem2;
for i:=1 to dem3 do
t1:=t1+e[i];
tbca:=t1/dem3;
writeln(‘trung binh cong cac so am la: ‘,tbca:4:2);
writeln(‘trung binh cong cac so duong la: ‘,tbcd:4:2);
readln;
end.
uses crt;
var a:array[1..100] of integer;
i,n,ln:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
readln(a[i]);
ln:=0;
for i:=1 to n do
if trunc(sqrt(A[i]))=sqrt(a[i]) then
begin
write(a[i]:4);
if ln<A[i] then ln:=A[i];
end;
writeln;
writeln('So chinh phuong lon nhat la: ',ln);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,x,y;
cout<<"Nhap n="; cin>>n;
x=n;
y=n+1;
if (x%2==0) cout<<x-2<<endl;
else cout<<x-1<<endl;
if (y%5==0) cout<<y;
else {
while (y%5!=0)
y++;
cout<<y;
}
return 0;
}
program TimMinMaxTrungBinh;
var
N, i, max, min, sum: integer;
a: array[1..50] of integer;
TB, minTB, maxTB: real;
begin
writeln('Nhap so nguyen duong N:');
readln(N);
sum := 0;
for i := 1 to N do
begin
write('Nhap so thu ', i, ': ');
readln(a[i]);
sum := sum + a[i];
end;
max := a[1];
min := a[1];
for i := 2 to N do
begin
if a[i] > max then
max := a[i];
if a[i] < min then
min := a[i];
end;
TB := sum / N;
minTB := TB;
maxTB := TB;
for i := 1 to N do
begin
if (a[i] < TB) and (a[i] < minTB) then
minTB := a[i];
if (a[i] > TB) and (a[i] > maxTB) then
maxTB := a[i];
end;
writeln('Gia tri lon nhat la: ', max);
writeln('Gia tri nho nhat la: ', min);
writeln('Gia tri trung binh la: ', TB:2:2);
if minTB = TB then
writeln('Khong co gia tri nao nho hon TB')
else
writeln('Gia tri nho nhat < TB la: ', minTB);
if maxTB = TB then
writeln('Khong co gia tri nao lon hon TB')
else
writeln('Gia tri lon nhat > TB la: ', maxTB);
readln;
end.
program SoMinMaxTrongMang;
var
A: array [1..50] of Integer;
n, i, min, max: Integer;
begin
Write('Nhap so phan tu cua mang: ');
Readln(n);
for i := 1 to n do
begin
Write('A[', i, ']= ');
Readln(A[i]);
end;
min := A[1];
max := 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('So lon nhat trong mang la: ', max);
WriteLn('So nho nhat trong mang la: ', min);
end.
#include <iostream>
using namespace std;
int main() {
int n;
cout << "Nhap vao mot so nguyen khong am: ";
cin >> n;
int count = 0;
for (int i = n + 1; i <= n * n; i++) {
if (i > 0) {
count++;
}
}
cout << "So luong so duong lon hon " << n << " va nho hon hoac bang " << n * n << " la: " << count << endl;
return 0;
}
2:
uses crt;
var a:array[1..100]of integer;
n,i:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
if a[i]<0 then write(i:4);
readln;
end.
Uses crt;
var n,i,max,min: integer;
a: array[1..100] of longint;
begin clrscr;
readln(n);
for i:=1 to n do read(a[i]); readln;
max:=a[1];
for i:=1 to n do if(max<a[i]) then max:=a[i];
writeln(max);
min:=a[1];
for i:=1 to n do if(min>a[i]) then min:=a[i];
writeln(min);
readln;
end.