Ответ:
#include <iostream>
using namespace std;
int main()
{
int num1, num2, max, min;
cout << "Введите два числа:" << endl;
cin >> num1 >> num2;
max = (num1 > num2) ? num1 : num2;
min = (num1 < num2) ? num1 : num2;
while (max % min != 0)
int temp = max % min;
max = min;
min = temp;
}
cout << "НОД: " << min << endl;
cout << "НОК: " << (num1 * num2) / min << endl;
return 0;
Объяснение:
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Verified answer
Ответ:
#include <iostream>
using namespace std;
int main()
{
int num1, num2, max, min;
cout << "Введите два числа:" << endl;
cin >> num1 >> num2;
max = (num1 > num2) ? num1 : num2;
min = (num1 < num2) ? num1 : num2;
while (max % min != 0)
{
int temp = max % min;
max = min;
min = temp;
}
cout << "НОД: " << min << endl;
cout << "НОК: " << (num1 * num2) / min << endl;
return 0;
}
Объяснение:
https://znanija.com/task/52037779