Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <cstdlib>
- #include <bits/stdc++.h>
- #include <algorithm>
- using namespace std;
- void sherry()
- {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- void fun(int n, int t[])
- {
- sort(t, t + n);
- cout << "The maximum number : " << t[n - 1] << "\n";
- cout << "The minimum number : " << t[0] << "\n";
- }
- bool prim(int a)
- {
- if (a < 2)
- {
- return false;
- }
- else
- {
- for (int i = 2; i <= sqrt(a); i++)
- {
- if (a % i == 0)
- return false;
- }
- return true;
- }
- }
- bool par(int a)
- {
- int s = a;
- int d, sum = 0;
- while (a > 0)
- {
- d = a % 10;
- sum = (sum * 10) + d;
- a /= 10;
- }
- if (s == sum)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- int countdis(int n, int t[])
- {
- int max = 0, ind = 0;
- for (int j = 0; j < n; j++)
- {
- int count = 0;
- for (int i = 1; i < t[j] / 2; i++)
- {
- if (t[j] % i == 0)
- count++;
- }
- if (max <= count)
- {
- max = count;
- ind = j;
- }
- }
- return t[ind];
- }
- int main()
- {
- sherry();
- int n, pr = 0, pa = 0;
- cin >> n;
- int t[n];
- for (int i = 0; i < n; i++)
- {
- cin >> t[i];
- }
- for (int i = 0; i < n; i++)
- {
- int s = t[i];
- if (prim(s))
- pr++;
- if (par(s))
- pa++;
- }
- fun(n, t);
- cout << "The number of prime numbers : " << pr << "\n";
- cout << "The number of palindrome numbers : " << pa << "\n";
- cout << "The number that has the maximum number of divisors : " << countdis(n, t);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement