Advertisement
JosepRivaille

P84732: Múltiple més petit

Apr 6th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. //Pre: LLegeix series de parells de naturals
  6. //Post: Escriu el natural més petit més gran que a i múltiple de b
  7. int main() {
  8.     int a, b, num = 0;
  9.     while (cin >> a >> b) {
  10.         ++num;
  11.         if (a%b == 0) cout << '#' << num << " : " << a << endl;
  12.         else {
  13.             a = a/b;
  14.             cout << '#' << num << " : " << b*a + b << endl;
  15.         }
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement