Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program baiso3;
- uses crt;
- type arr=array [1..1000] of real;
- var a,b:arr;
- p,n,i,j:integer;
- flag:byte;
- traloi: char;
- function doi(x:integer; y:integer) : real;
- var k, th:integer;
- begin
- th:=0;
- for k:=0 to (x-1) do th:=th+k;
- th:=th+y;
- doi:=a[th];
- end;
- procedure yeucau;
- begin
- writeln('He phuong Trinh Tuyen Tinh');
- writeln('You Are already');
- write('Yes Or No: (Y/N) '); readln(traloi);
- If traloi in ['y','Y'] then
- begin
- writeln('Nhap he phuong trinh vao de');
- writeln('Any key to continute.......');
- readln;
- end;
- end;
- procedure nhap;
- var dem:byte;
- begin
- begin
- yeucau;
- end;
- write('nhap so phuong trinh:'); readln(n);
- p:=0;
- for i:=1 to n do
- begin
- dem:=0;
- write('Phuong trinh ',i , ' : ');
- writeln;
- for j:=1 to i do
- begin
- write(' co he so thu ',j,' = ');
- readln(a[p+j]);
- if a[p+j]=0 then inc(dem);
- end;
- p:=p+i;
- write(' Nhap he so ve phai b[',i,']=');
- readln(b[i]);
- if (a[p]=0) and (b[i]<>0) then flag:=1 ;
- if (dem=i) and (b[i]=0) then flag:=2;
- end;
- end;
- procedure tinhnghiem;
- begin
- b[1]:=b[1]/doi(1,1);
- for i:=2 to n do
- begin
- for j:=1 to i-1 do
- b[i] := b[i]- (doi(i,j)*b[j]);
- b[i]:=b[i]/doi(i,i);
- end;
- write('Nghiem cua he la:');
- for i:=1 to n do
- write(b[i]:0:2,' ');
- end;
- procedure giaihe;
- begin
- if flag=1 then
- write ('He phuong trinh vo nghiem')
- else
- if flag=2 then
- write('He co vo so nghiem')
- else
- tinhnghiem;
- end;
- begin
- clrscr;
- nhap;
- giaihe;
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement