Вот тебе простой вариант ришение задачи (коментар=пояснение)
PascalВыделить код
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 program prg; uses crt; var rez,chislo,min,max:integer; begin Write('Enter number = ');readln(chislo); //zanosim 1 chislo max:=chislo; //v max ta min min:=chislo; //chtobu potom mu soukb sravnivat s drugimi chislamu while (chislo<>0) do //zapuskaem zikl poka mu ne napishem 0 begin if (chislo>max)then max:=chislo; //sravnivaem s max if (chislo<min) then min:=chislo; //sravnivaem s min readln(chislo); //snova pihem chislo end; rez:=(max-min); //nahodim raznizy writeln('max(',max,') - min(',min,') = ',rez); //otvet end.
#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");
}
Объяснение: