Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int gcd(int a, int b) {
- while (b != 0) {
- int temp = b;
- b = a % b;
- a = temp;
- }
- return a;
- }
- int main() {
- int numerator, denominator;
- std::cout << "Въведете числител и знаменател: ";
- std::cin >> numerator >> denominator;
- int common_divisor = gcd(numerator, denominator);
- int reduced_numerator = numerator / common_divisor;
- int reduced_denominator = denominator / common_divisor;
- std::cout << "Изход: " << reduced_numerator << " " << reduced_denominator << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment