
#include <iostream>
#include <string>
using namespace std;
string fn(unsigned value, unsigned base) {
static string box;
if (!value) {
auto x = box;
box.clear();
return string(x.rbegin(), x.rend());
}
box += to_string(value % base);
value /= base;
return fn(value, base);
}
int main() {
unsigned base, value;
cin >> base >> value;
auto result = fn(value, base);
cout << value << "(10)=" << result << "("<< base << ")\n";
system("pause > nul");
}
Объяснение:
const
handsfree = false;
nmax = 10;
random_min = -50;
random_max = 50;
var
a: array[0..nmax] of real;
i, n: integer;
sum, x: real;
begin
{ввод массива}
n := nmax;
if handsfree then begin
for i := 0 to n do
begin
a[i] := random(random_max - random_min) + random_min;
write(a[i], ' ');
end
end
else begin
for i := 0 to n do
readln(a[i]);
end;
writeln();
{подсчет суммы}
write('x = ');
readln(x);
sum := a[n];
for i := n - 1 downto 0 do
sum := sum * x + a[i];
writeln('S = ', sqrt(sum));
end.