Advertisement
DMG

Razdvojiti proste od slozenih (S)

DMG
Apr 2nd, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. // dragutinmarjanovic
  2. #include <iostream>
  3.  
  4. bool prost(int n)
  5. {
  6.      for (int i=2; i<n; i++)
  7.          if (n%i==0)
  8.          return false;
  9.          
  10.      return true;
  11. }
  12.  
  13. using namespace std;
  14. main()
  15. {
  16.       int n, a[1000], s;
  17.      
  18.       cin >> n;
  19.      
  20.       for (int i=0; i<n; i++)
  21.       cin >> a[i];
  22.      
  23.       for (int j=0; j<2; j++)
  24.           for (int i=0; i<n; i++)
  25.               if (j==0)
  26.                  {if (prost(a[i])==true) cout << a[i] << " ";}
  27.               else
  28.                  {if (prost(a[i])==false) cout << a[i] << " ";}
  29.      
  30.       cout << endl;
  31.      
  32.       system ("PAUSE");      
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement