esercizi di matematica con turbo pascal 1.1 su mac
program kramer5; (* regola pratica per determinante terzo ordine *) (* soluzione sistema a tre equazioni *) (* variante di kramer3 .. numeri reali o interi *)
var a1,a2,a3,b1,b2,b3,c1,c2,c3,n1,n2,n3:real; ds,dx,dy,dz,x,y,z:real; s:string; scelta,T:integer;
procedure fine; begin exit; end;
procedure impossibile; begin writeln('sistema impossibile'); end;
procedure indeterminato; begin writeln('sistema indeterminato o impossibile'); writeln('premi enter'); readln; end;
procedure determinato; begin writeln('sistema determinato:soluzioni='); writeln('determinante sistema ds=',ds:4:3); writeln('determinante incognita dx=',dx:4:3); writeln('determinante incognita dy=',dy:4:3); writeln('determinante incognita dz=',dz:4:3); writeln('X = ',dx/ds:4:3); writeln('Y = ',dy/ds:4:3); writeln('Z = ',dz/ds:4:3); writeln; writeln('premi enter'); readln; end;
procedure calcola; begin clearscreen; s:=' '; writeln('calcolo determinante terzo ordine:regola di SARRUS '); writeln('soluzione sistema con tre equazioni e tre incognite '); writeln('scrivi i valori dei coefficienti e termini noti'); writeln('se valori con decimali usa punto decimale 5.3 '); writeln('dopo ogni valore premere enter '); writeln('prova con seguenti valori '); writeln('1,2,3,4...2,4,6,8..3,6,9,12 indeterminato '); writeln('2,1,2,1...-3,2,-2,2..12,-1,10,4 impossibile '); writeln('1,2,3,4...7,3,9,8...2,1,6,3 determinato '); writeln('------------------'); writeln('a1 b1 c1 n1'); writeln('a2 b2 c2 n2'); writeln('a3 b3 c3 n3'); writeln('-------------------'); write('a1=');readln(a1); write('b1=');readln(b1); write('c1=');readln(c1); write('n1=');readln(n1); write('a2=');readln(a2); write('b2=');readln(b2); write('c2=');readln(c2); write('n2=');readln(n2); write('a3=');readln(a3); write('b3=');readln(b3); write('c3=');readln(c3); write('n3=');readln(n3); writeln('--------------------'); writeln(a1:4:3,s,b1:4:3,s,c1:4:3,s,n1:4:3); writeln(a2:4:3,s,b2:4:3,s,c2:4:3,s,n2:4:3); writeln(a3:4:3,s,b3:4:3,s,c3:4:3,s,n3:4:3); writeln; ds:=a1*b2*c3+b1*c2*a3+c1*a2*b3-a3*b2*c1-b3*c2*a1-c3*a2*b1; dx:=n1*b2*c3+b1*c2*n3+c1*n2*b3-n3*b2*c1-b3*c2*n1-c3*n2*b1; dy:=a1*n2*c3+n1*c2*a3+c1*a2*n3-a3*n2*c1-n3*c2*a1-c3*a2*n1; dz:=a1*b2*n3+b1*n2*a3+n1*a2*b3-a3*b2*n1-b3*n2*a1-n3*a2*b1; if (ds<>0) then T:=1 else if (ds=0) and (dx=0) and (dy=0) and (dz=0) then T:=2 else if (ds=0) and (dx<>0) or (dy<>0) or (dz<>0) then T:=3 else; case T of 1:determinato; 2:indeterminato; 3:impossibile; end; writeln('-----------------------------------'); writeln('premi 1 per altro calcolo'); writeln('premi 2 per finire'); write('scelta 1 o 2 ? ');readln(scelta); case scelta of 1:calcola; 2:fine; end; end;
begin clearscreen; calcola; end.