Advertisement
DMG

Igra (S)

DMG
Apr 3rd, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool prost(int n)
  5. {
  6.      for (int i=2; i<n; i++)
  7.      if (n%i==0)
  8.         return false;
  9.      return true;
  10. }
  11.  
  12. int koji_prosti(int n)
  13. {
  14.     int s = 4;
  15.    
  16.     for (int i=6; i<n; i++)
  17.     if (prost(i)==true)
  18.        s++;  
  19.     return s;
  20. }
  21.  
  22. main()
  23. {
  24.       int n, k[1000], m[1000], ivica=0, haso=0;
  25.      
  26.       cin >> n;
  27.      
  28.       for (int i=0; i<n; i++)
  29.       {
  30.           cin >> k[i] >> m[i];
  31.           if (koji_prosti(m[i])==k[i])
  32.              ivica++;
  33.       }
  34.      
  35.       for (int i=0; i<n; i++)
  36.       {
  37.           cin >> k[i] >> m[i];
  38.           if (koji_prosti(m[i])==k[i])
  39.              haso++;
  40.       }
  41.      
  42.       // cout << ivica << ":" << haso << endl;
  43.      
  44.       if (ivica>haso)
  45.       cout << "Ivica";
  46.       else if (haso>ivica)
  47.       cout << "Haso";
  48.       else
  49.       cout << "Nerijeseno";
  50.      
  51.       cout << endl;
  52.            
  53.       system("PAUSE");
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement