Advertisement
DMG

Dobar broj

DMG
Mar 8th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. main()
  4. {
  5.       int p,s,n;
  6.       bool b;
  7.       cin >> n;
  8.       s=0;
  9.       b=true;
  10.       do
  11.       {
  12.           s = s + n % 10;
  13.           p = n / 10 % 10;
  14.           n = n / 10;
  15.           if (p<=s)
  16.           b = false;
  17.       }
  18.       while (b==true && n>10);
  19.       if (b==true)
  20.       cout << "Broj je dobar!" << endl;
  21.       else cout << "Broj je los!" << endl;
  22.       system ("PAUSE");
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement