Facebook
From Buff Plover, 1 Year ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 137
  1. #include<iostream>
  2. #include<math.h>
  3. using namespace std;
  4. bool nguyento(int n)
  5. {
  6.         if(n<2)
  7.           return false;
  8.         for (int i=2; i<=sqrt(n);i++)
  9.         {
  10.                 if (n%i==0)
  11.                 return false;
  12.         }
  13.         return true;
  14.        
  15. }
  16. bool kiemtra(int n)
  17. {
  18.        
  19.         for(;n>0;n/=10)
  20.         {
  21.                 if(n%10==nguyento(n))
  22.                  return 1;
  23.         }
  24.         return n;
  25. }      
  26. int main()
  27. {
  28.         int n;
  29.         cin>>n;
  30.         if(kiemtra(n))
  31.           cout << 1;
  32.         else
  33.            cout<<0;
  34.    return 0;
  35. }

Replies to Untitled rss

Title Name Language When
Re: Untitled Bitty Lemur cpp 1 Year ago.