//Вот программа, которая кодирует слова в системах счисления от 2 до 10 //Первый ввод - число, второй - система счисления //Pascal ABC.NET v3.0
var a,i,b,r,n,j,bug:integer; s,se,slo,slof:string;
procedure preob(var a,b,n:integer; var se:string); begin repeat b:=a mod n; a:=a div n; str(b,se); s+=se; until (a<=n-1); end;
begin readln(slo); readln(n); for j:=1 to length(slo) do begin; a:=ord(slo[j]); preob(a,b,n,se); str(a,se); s+=se; for i:=1 to length(s) div 2 do begin; se:=s[i]; s[i]:=s[length(s)-i+1]; s[length(s)-i+1]:=se[1]; end; write(s,'-'); slof:=slof+s; delete(s,1,length(s)); end; end.
//Слово Программа она кодирует как 11001111-11110000-11101110-11100011-11110000-11100000-11101100-11101100-11100000-
' QBASIC CONST n = 10 DIM a(1 TO n) AS DOUBLE, b(1 TO n) AS DOUBLE, x(1 TO n) AS DOUBLE RANDOMIZE TIMER CLS FOR i = 1 TO n a(i) = 50 * RND - 25 b(i) = 50 * RND - 25 IF a(i) <> 0 THEN x(i) = b(i) / a(i) ELSE x(i) = 0 END IF PRINT USING "###."; a(i); PRINT " * "; PRINT USING "###."; x(i); PRINT " = "; PRINT USING "###."; b(i) NEXT i
//Первый ввод - число, второй - система счисления
//Pascal ABC.NET v3.0
var
a,i,b,r,n,j,bug:integer;
s,se,slo,slof:string;
procedure preob(var a,b,n:integer; var se:string);
begin
repeat
b:=a mod n;
a:=a div n;
str(b,se);
s+=se;
until (a<=n-1);
end;
begin
readln(slo);
readln(n);
for j:=1 to length(slo) do
begin;
a:=ord(slo[j]);
preob(a,b,n,se);
str(a,se);
s+=se;
for i:=1 to length(s) div 2 do
begin;
se:=s[i];
s[i]:=s[length(s)-i+1];
s[length(s)-i+1]:=se[1];
end;
write(s,'-');
slof:=slof+s;
delete(s,1,length(s));
end;
end.
//Слово Программа она кодирует как 11001111-11110000-11101110-11100011-11110000-11100000-11101100-11101100-11100000-
CONST n = 10
DIM a(1 TO n) AS DOUBLE, b(1 TO n) AS DOUBLE, x(1 TO n) AS DOUBLE
RANDOMIZE TIMER
CLS
FOR i = 1 TO n
a(i) = 50 * RND - 25
b(i) = 50 * RND - 25
IF a(i) <> 0 THEN
x(i) = b(i) / a(i)
ELSE
x(i) = 0
END IF
PRINT USING "###."; a(i);
PRINT " * ";
PRINT USING "###."; x(i);
PRINT " = ";
PRINT USING "###."; b(i)
NEXT i
Тестовое решение:
-14.65854 * 0.53867 = -7.89606
-14.19729 * 1.08311 = -15.37722
-17.21156 * -0.07488 = 1.28888
16.17024 * -1.09750 = -17.74690
-13.80126 * -1.06180 = 14.65417
17.78583 * 0.83055 = 14.77207
-10.95534 * -1.58899 = 17.40791
-11.84992 * 1.66222 = -19.69714
-24.91831 * -0.95948 = 23.90864
-12.68757 * 0.84160 = -10.67785