h>
#include <iostream.h>
#include<time.h>
clock_t start, end;
//---------------------------------------------------------------------------
int recursion(unsigned long n)
{ if (n < 10)// Базовый случай
{ return n; }
else { // Шаг рекурсии
cout<< n %10<< endl;
return recursion(n / 10);
}}
int main()
{ unsigned long n; int c=9;
int t=0;
std::ofstream out; // поток для записи
out.open("C:\\lida1.txt", std::ios::app); // создаём объект класса ofstream для записи и связываем
его с файлом Txt.txt
setlocale (LC_ALL,".866");
while(!(c==0))
{wprintf(L"Введите число\n");
cin>> n; cout<< endl;
out << "число: " << n<< std::endl;
wprintf(L"Рекурсия \n");
start=clock();
for( int i=0; i<100000000; i++) {t++;}
cout<< recursion(n)<<endl ;
end=clock();
wprintf(L"Время 1 :"); cout<<end-start; wprintf(L"mc \n");
out << "рекурсия: " << end-start <<" mc"<< std::endl;
cout<<endl;
wprintf(L"Интерация \n");
start = clock();
for( int i=0; i<100000000; i++) {t++;}
cout<< interac( n)<< endl;
end=clock();
wprintf(L"Время 2 :"); cout<< end-start; wprintf(L"mc \n");
out << "интерации: " << end-start <<" mc"<< std::endl<< std::endl;
wprintf(L"1 - повторить \n");
wprintf(L"0 - Выход \n");
cin>> c; cout<< endl;
}
out.close(); //Закрываем файл
return 0;
}