Advertisement
Stinsfire

Cpp 1. zadatak

Jan 28th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4. void prim(int a);
  5.  
  6. int main(){
  7.  
  8.     int a;
  9.    
  10.     cin>>a;
  11.    
  12.     prim(a);
  13.        
  14.          
  15.     system ("pause");
  16.     return 0;  
  17. }
  18.  
  19. void prim(int a){
  20.      
  21.      int b;
  22.      
  23.      for(int i=a-1;i>1;i--){
  24.              
  25.              if(a%i==0){
  26.              b++;
  27.              }
  28.      }
  29.      
  30.      if(b==0 && a!=2){
  31.               cout<<"Upisani broj je prim."<<endl;
  32.               }
  33.      else cout<<"Upisani broj nije prim."<<endl;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement