Witam,
jako, ze na lekcjach Systemow Informatycznych poruszamy programowanie, a naszym jezykiem (niestety) jest Pascal, to postanowilem, sprobowac napisac maly kalkulator. Problem wystepuje w pewnej funkcji, a doklanie w funkcji division. Nie za bardzo rozumiem gdzie lezy problem, bo cala reszta funkcji jest napisana podobnie i nie ma z nimi problemu.
program calc;
uses
crt;
var
mathAktion : Integer;
X, Y : Integer;
result : Longint;
function addition ( X, Y : Integer ) : Longint;
begin
Write ( 'x: ' );
ReadLn (X);
Write ( 'y: ');
Readln (Y);
result := X + Y;
Writeln ( X ,' + ', Y, ' = ', result );
ReadLn;
end;
function substraction ( X, Y : Integer ) : Longint;
begin
Write ( 'x: ' );
ReadLn (X);
Write ( 'y: ');
Readln (Y);
result := X - Y;
Writeln ( X ,' - ', Y, ' = ', result );
ReadLn;
end;
function multiplication ( X, Y : Integer ) : Longint;
begin
Write ( 'x: ' );
ReadLn (X);
Write ( 'y: ');
Readln (Y);
result := X * Y;
Writeln ( X ,' * ', Y, ' = ', result );
ReadLn;
end;
function division ( X, Y : Integer ) : Longint;
begin
Write ( 'x: ' );
ReadLn (X);
Write ( 'y: ');
Readln (Y);
result := X / Y;
Writeln ( X ,' / ', Y, ' = ', result );
ReadLn;
end;
begin
WriteLn ( ' Tafelwerkumsetzung auf Tachenrechner. ' );
WriteLn ( ' 1. Addition ' );
WriteLn ( ' 2. Substraktion ' );
WriteLn ( ' 3. Multiplikation ' );
WriteLn ( ' 4. Division ' );
WriteLn ( ' 5. Potenze ' );
WriteLn ( ' 6. Wurzel ' );
WriteLn ( ' 7. Gleichungen ' );
WriteLn ( ' 8. Planimetrie ' );
WriteLn ( ' 9. Ebene Trigonometrie ' );
Read (mathAktion);
case (mathAktion) of
1:
Writeln ( addition ( X, Y ) );
2:
Writeln ( substraction ( X, Y ) );
3:
Writeln ( multiplication ( X, Y ) );
4:
Writeln ( addition ( X, Y ) );
5:
Writeln ( addition ( X, Y ) );
6:
Writeln ( addition ( X, Y ) );
7:
Writeln ( addition ( X, Y ) );
8:
Writeln ( addition ( X, Y ) );
9:
Writeln ( addition ( X, Y ) );
else
ReadLn;
end;
ReadLn;
end.
Bylbym wdzieczny, gdyby mi ktos wytlumaczyl, gdzie lezy blad, bo dla mnie jest to lekko komiczny jezyk.
Pozdrawiam DC