vlatkovski

Moj broj

Aug 8th, 2016
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. void novKrug();
  7. int pX = 0, pY = 0, gX = 0, gY = 0; //poeni x, poeni y, najgolem x, najgolem y
  8.  
  9.  
  10. int main() {
  11.  
  12.     novKrug();
  13.     novKrug();
  14.     novKrug();
  15.  
  16.     string pobednik = "";
  17.  
  18.     if (pX == pY) {
  19.         pobednik = gX > gY ? "Stefan" : "Ana";
  20.     } else {
  21.         pobednik = pX > pY ? "Stefan" : "Ana";
  22.     }
  23.  
  24.     cout << pX << " " << pY << "\n" << pobednik << "\n";
  25.  
  26.     return 0;
  27. }
  28.  
  29.  
  30. int zbirNaCifri(int n) {
  31.     int sum = 0;
  32.     while (n > 0) {
  33.         sum += n % 10;
  34.         n /= 10;
  35.     }
  36.     return sum;
  37. }
  38.  
  39. void novKrug() {
  40.     int x, y;
  41.     cin >> x >> y;
  42.  
  43.     if (x % zbirNaCifri(x) == 0) {
  44.         pX += 2;
  45.         pY -= 1;
  46.  
  47.         gX = x > gX ? x : gX;
  48.     }
  49.  
  50.     if (y % zbirNaCifri(y) == 0) {
  51.         pY += 2;
  52.         pX -= 1;
  53.  
  54.         gY = y > gY ? y : gY;
  55.     }
  56. }
Add Comment
Please, Sign In to add comment