Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void init(int& n);
- bool isPrime(int x);
- int result(int n);
- void coutResult(int t);
- int main() {
- int n;
- init(n);
- int t = result(n);
- coutResult(t);
- }
- void init(int& n) {
- scanf("%d", &n);
- }
- bool isPrime(int x) {
- if (x == 1 || x == 0) return false;
- for (int i = 2; i < x; i++) {
- if (x % i == 0) return false;
- }
- return true;
- }
- int result(int n) {
- int count = 0;
- while (n > 0) {
- int x = n % 10;
- if (isPrime(x)) count++;
- n /= 10;
- }
- return count;
- }
- void coutResult(int t) {
- printf("%d", t);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement