Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project2;
- {$APPTYPE CONSOLE}
- uses
- SysUtils, Math;
- Function InCase(str: String; toch:Integer) : Double;
- var i, chislo: Integer;
- var number: Double;
- begin
- number:=0;
- for i:=1 to toch do
- begin
- case str[i] of
- '1': chislo:=1;
- '2': chislo:=2;
- '3': chislo:=3;
- '4': chislo:=4;
- '5': chislo:=5;
- '6': chislo:=6;
- '7': chislo:=7;
- '8': chislo:=8;
- '9': chislo:=9;
- '0': chislo:=0;
- else begin
- writeln('Ne verno zadano chislo');
- readln;
- exit; //or result
- end;
- end;
- number:=number + chislo*Power(10, (toch-i));
- end;
- Result := number;
- end;
- var
- a,b: String;
- i,tochka, tochka2, chislo, n, n2, test: Integer;
- a_f, a_f2, b_f, b_f2: Double;
- begin
- writeln('Vvedite pervoje chislo');
- readln(a);
- writeln('Vvedite vtoroje chislo');
- readln(b);
- writeln('Vy vveli chisla: ', a, ' i ', b);
- tochka:=0;
- n:=length(a); //dlina pervoj stroki
- for i:=1 to n do
- if(a[i] = '.') or (a[i] = ',') then
- begin //nahodim gde nahoditsia tochka v pervom chisle
- tochka:=i-1;
- break;
- end;
- tochka2:=0;
- n2:=length(b); //dlina vtoroj stroki
- for i:=1 to n do
- if(b[i] = '.') or (b[i] = ',') then //nahodim gde nahoditsia tochka vo vtorom chisle
- begin
- tochka2:=i-1;
- break;
- end;
- if(tochka<>0) then
- a_f:=InCase(a, tochka)
- else a_f:=InCase(a, n);
- if(tochka2<>0) then
- b_f:=InCase(b, tochka2)
- else b_f:=InCase(b, n2);
- if(tochka<>0) then
- begin
- Delete(a, 1, tochka+1);
- n:=n-tochka-1;
- a_f2:=InCase(a, n);
- end;
- if(tochka2<>0) then
- begin
- Delete(b, 1, tochka2+1);
- n2:=n2-tochka2-1;
- b_f2:=InCase(b, n2);
- end;
- test:=1;
- for i:=1 to n do
- test:=test*10;
- a_f:=a_f+a_f2/test;
- test:=1;
- for i:=1 to n2 do
- test:=test*10;
- b_f:=b_f+b_f2/test;
- a_f:=a_f+b_f;
- Writeln('Summa chisel = ', a_f:0:5);
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement