عبد السلام نصير
2009-01-24, 07:20
أبحث عن برنامج باسكال يكتب معادلة من الدرجة الثانية
عبد السلام نصير
2009-01-26, 13:21
هل من مجيب على هذا السؤال
Program Delta_Equality;
var
Equality:String;
Pointer:Integer;
X2Find:Boolean;
XFind:Boolean;
EqualFind:Boolean;
A:string; AI:Integer;
B:string; BI:Integer;
C:string; CI:Integer; Code:Integer; Delta:Integer;
Begin
Writeln('Enter the equality in the simple mode ');
writeln('as the following +- A X^ +- B X +- C = 0 ... X^ = X * X');
writeln('');
writeln('');
{Read the Equality} readln(Equality);
for Pointer:=1 to length(equality) do
Begin {Beginnig of the For}
case equality[Pointer] of
'X','x':
if(equality[Pointer]+equality[Pointer+1]='X^')or(equality[Pointer]+equality[Pointer+1]='x^') then if Pointer=1 then
begin
A:=A+'1';
X2Find:=true;
end else X2Find:=true else
if X2Find=false then writeln('You did not enter the X^...') else XFind:=true;
'=':
if X2Find=false then writeln('You did not enter the X^...') else
if XFind=false then writeln('You did not enter the X ...') else equalfind:=true;
'0'..'9':
if (X2Find=true)and(XFind=true)and(equalfind=true)and (equality[Pointer]<>'0')
then
begin
writeln('You did not enter the equlity in the simple mode !!!!');
Equality:='';
readln(Equality);
end else
if X2find=false then A:=A+equality[Pointer] else
if (X2Find=true)and(XFind=false)then B:=B+equality[Pointer] else
if (X2Find=true)and(XFind=true)and(equalfind=false)th en C:=C+equality[Pointer];
'-','+':
if X2Find=false then A:=Equality[Pointer] else
if (X2Find=true)and(XFind=false)and(equalfind=false)t hen B:=Equality[Pointer] else
if (X2Find=true)and(XFind=true)and(equalfind=false)th en C:=Equality[Pointer];
end;{End of the Case}
if Pointer=length(Equality)then
begin
writeln('A = ',A,' ','B =',B,' ','C = ',C);
writeln('');
val(A,Ai,Code);val(B,Bi,Code);val(C,Ci,Code);
Delta:=sqr(Bi)-(4*Ai*Ci);
writeln('Delta = ',Delta);
if Delta<0 then writeln('There is no solution for this equality in real numbers ...')else
if Delta=0 then writeln('The answer is : ', 'X1 = X2 = ', - Bi/(2*Ai))else
if Delta>0 then
writeln('The answer is : ', 'X1 = ', (- Bi - sqrt(Delta))/(2*Ai),' ............ ','X2 = ', (- Bi + sqrt(Delta))/(2*Ai) );
end;
end;{End of the For}
readln;readln;
end.
للأمانة منقولة
عبد السلام نصير
2009-01-28, 06:58
merci...............................