اینجا هستید : safarionline.ir / books / cpp / ch01

Integer Arithmetic

  1. Raise integer to a positive power. Repeat reading pairs of integers, until you encounter a 0. Indicate invariant loop.

    Mohsen   ➡ Wirth


  1. Divide an integer by a natural number, using operations of addition, subtraction, doubling and halving only. Repeat reading pairs of integers, until you encounter a 0. For each pair, print dividend, divosor, quotient, and remainder. Indicate invariant of loop.

  1. Compute the greatest common divisor (gcd) and the lowest common multiple (lcm) of two natural numbers by using addition and subtraction only. Note that gcd(m, n) * lcm(m, n) = m * n . Repeat reading pairs of integers, until you encounter a 0. For each pairs, print the arguments, the gcd and the lcm. Indicate the invariant loop.

  1. Compute the greatest common divisor (gcd) of two natural numbers. Use addition, subtraction, doubling and halving only.

  1. Compute the largest integer less or equal to the square root of a given integer (due to Hoare).
© کلیه‌ی حقوق برای safarionline.ir محفوظ است.