1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
| // conver number cc K.cpp: определяет точку входа для консольного приложения.
//
#include "stdafx.h"
#include <iostream>
#include <windows.h>
using namespace std;
char int_symbol(int in){
char out[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
return out[in];
}
void ten_base(int in, int base){
if (in<base) {
std::cout << int_symbol(in);
return;
}
ten_base(in / base, base);
std::cout << int_symbol(in%base) ;
}
//вычисляем факториал
int fact(int x)
{
if (x == 1)
return 1;
else
return x*fact(x - 1);
}
int main(){
//setlocale(LC_ALL, "");
SetConsoleOutputCP(1251);
SetConsoleCP(1251);
int in;
int base;
cout << "Ведите число" << endl;
std::cin >> in;
int m = fact(in);
cout << "факториал числа " << in << "!=" << m<< endl;
cout << "Ведите конечную систему счисления" << endl;
std::cin >> base;
cout << "Результат перевода факториала в к ричную систему" << endl;
ten_base(m, base);
cout << endl;
system("pause");
return 0;
} |