Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int sumcif(int x)
- {
- int s = 0;
- do
- {
- s += x % 10;
- x /= 10;
- }
- while(x);
- return s;
- }
- int testprim(int x)
- {
- if (x % 2 == 0 || x == 1)
- return 0;
- for (int i = 3; i * i <= x; i += 2)
- if (x % i == 0)
- return 0;
- return 1;
- }
- void citire(int& n, int v[])
- {
- cin >> n;
- for (int i = 0; i < n; i++)
- cin >> v[i];
- }
- int n, v[1000];
- int main()
- {
- int k = 0;
- citire(n, v);
- for (int i = 0; i < n; i++)
- if(testprim(sumcif(v[i])))
- k++;
- cout << k;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement