1b0x

Numbers

May 2nd, 2016
137
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.  
  4. int main() {
  5.  
  6.     int a, b, k, br = 0;
  7.  
  8.     do {
  9.         cout << "a = "; cin >> a;
  10.     } while (a < 0 || a > 10);
  11.  
  12.     do {
  13.         cout << "b = "; cin >> b;
  14.     } while (b < 0 || b > 10);
  15.  
  16.     do {
  17.         cout << "k = "; cin >> k;
  18.     } while (k < 1 || k > 100);
  19.  
  20.     for (int i = 0; i <= 9; i++)
  21.     {
  22.         if ((a * 100 + i * 10 + b * 1) % k == 0)
  23.             br++;
  24.     }
  25.  
  26.     cout << br << endl;
  27.  
  28.     system("pause");
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment