#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n, a[100] = {}, a2[100] = {}, a3[100] = {};
int tbcchan = 0, tbcle = 0, max, min, vitrimin = 0, dem2 = 0, dem3 = 0, demtbc = 0, temp = 0;
bool A = 0;
//them phan tu cho mang goc
cout << "Nhap n: "; cin >> n;
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
max = a[0]; min = a[0];
for (int i = 0; i < n; i++)
{
//chuan bi cho tinh tbc chan le
if (a[i] % 2 == 0)
{
tbcchan += a[i];
demtbc += 1;
}
else
{
tbcle += a[i];
}
// chuan bi cho max min
if (a[i] > max)
{
max = a[i];
}
if (a[i] < min)
{
min = a[i];
vitrimin = i;
}
//so chinh phuong
if (pow(int(sqrt(a[i])), 2) == a[i])
{
a2[dem2] = a[i];
dem2 += 1;
}
//so nguyen to
if (a[i] == 2 || a[i] == 3)
{
a3[dem3] = a[i];
dem3++;
}
else
{
for (int j = 1; j < sqrt(a[i]); j++)
{
if (a[i] % j == 0)
{
A = 1;
break;
}
}
if (A == 0)
{
a3[dem3] = a[i];
dem3++;
}
A = 0;
}
}
//kq1
if (demtbc == 0)
{
cout << "TBC chan: 0 TBC le: " << tbcle / n;
}
else if (demtbc == n)
{
cout << "TBC chan: " << tbcchan / n << "TBC le: 0";
}
else
{
cout << "TBC chan: " << tbcchan / demtbc << " " << "TBC le: " << tbcle / (n - demtbc);
}
cout << "\nSo lon nhat: " << max;
cout << "\nVi tri so be nhat: " << vitrimin;
//kq4
cout << "\nCo " << dem2 << " so chinh phuong la: ";
for (int i = 0; i < dem2; i++)
{
cout << a2[i] << " ";
}
//kq5
cout << endl << "Cac so nguyen to trong mang: ";
for (int i = 0; i < dem3; i++)
{
cout << a3[i] << " ";
}
//sap xep thu tu tang dan
for (int i = 0; i < n; i++)
{
temp = a[i];
for (int j = i ;j < n; j++)
{
if (a[i] < a[j])
{
a[i] = a[j];
a[j] = temp;
temp = a[i];
}
}
}
cout << "\n";
for (int i = 0; i < n; i++)
{
cout << a << " ";
}
}
Cho em hỏi phần số nguyên tố em bị gì mà khong thể in được vậy ạ?