Facebook
From Nihad, 3 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 90
  1. // Example program
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. class Sade{
  8.     public:
  9.     bool yoxla(int a){
  10.         for(int i = 2; i< a/2; i++){
  11.             if(a%i==0){
  12.                 return false;
  13.             }
  14.         }
  15.         return true;
  16.     }
  17.    
  18.     bool sol(int a){
  19.         while(a>9){
  20.             a=a/10;
  21.         }
  22.         if(a%2==0)
  23.             return true;
  24.         return false;
  25.     }    
  26. };
  27.  
  28. int main()
  29. {
  30.     Sade obje;
  31.    
  32.     int a[]= {13,45,23,21,29,17};
  33.     cout<<"Sadedir->"<<endl;
  34.     for(int i = 0; i<sizeof(a)/sizeof(int); i++){
  35.         if(obje.yoxla(a[i]) && obje.sol(a[i]))
  36.             cout<<a[i]<<endl;
  37.     }
  38.    
  39.     return 0;
  40. }
  41.  

Replies to Proq1 rss

Title Name Language When
Re: Proq1 Nihad cpp 3 Years ago.