Advertisement
sellmmaahh

tut2-zad1

Jul 20th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4.  
  5.  
  6. bool DaLiJeProst (int n) {
  7.     for (int i=2; i<n; i++) {
  8.         if (n%i==0) return false;
  9.     }
  10.     return true;
  11.     }
  12.  
  13.  
  14. int main ()
  15. {
  16.     std::cout<<"Unesite dva cijela broja: ";
  17.     int a,b;
  18.     std::cin>>a>>b;
  19.     for (int i=a; i<b; i++) {
  20.         if (DaLiJeProst(i)==true) std::cout<<"Broj "<<i<<" je prost."<<std::endl;
  21.          if (DaLiJeProst(i)==false) std::cout<<"Broj "<<i<<" nije prost. "<<std::endl; }
  22.         return 0;
  23.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement