Уважаемые эксперты! Пожалуйста, ответьте на вопрос:
Дописать функцию рекурсии.
// Найти НОД (наибольший общий делитель) двух натуральных чисел.
#include <iostream>
#include <stdio.h>
#include <string>
#include <fstream>
using namespace std;
int nod(int a, int b) // наибольший делитель
{
int res;
int c = (a > b) ? b : a;
for (int i = 1; i <= c; i++)
if ((a % i == 0) && (b % i == 0))
res = i;
return res;
}
int rec(int a, int b)
{
}
int main()
{
string pach = "FileDate";
ofstream output;
output.open(pach);
if (!output.is_open())
{
cout << "Ошибка при открытии файла";
}
else
{
cout << "Файл сейчас открыт" << endl;
}
setlocale(LC_ALL, "Russian");
srand(time(0)); // для времени
int a;
int b;
int res;
cout << "Vvedite" << endl;
cin >> a;
cin >> b;
output << "Vvedite" << endl << a << endl << b << endl;
cout << "Otvet" << endl << nod(a,b) << endl;
output << "Otvet" << endl << nod(a, b) << endl;
cout << "runtime = " << clock() / 1000.0 << endl; // время работы программы
output << "runtime = " << clock() / 1000.0 << endl; // время работы программы
system("pause");
return 0;
}