intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

đề thực hành pascal

Chia sẻ: Nguyen Van | Ngày: | Loại File: DOC | Số trang:59

246
lượt xem
77
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

THUC HANH 1 program bt1th1; Var a,b,c:real; delta,x,x1,x2:real; Begin writeln('GIAI PHUONG TRINH BAC 2 '); repeat write('Nhap he so a='); readln(a); until a0; write('Nhap he so b='); readln(b);

Chủ đề:
Lưu

Nội dung Text: đề thực hành pascal

  1. THUC HANH 1 program bt1th1; Var a,b,c:real; delta,x,x1,x2:real; Begin writeln('GIAI PHUONG TRINH BAC 2 '); repeat write('Nhap he so a='); readln(a); until a0; write('Nhap he so b='); readln(b); write('Nhap he so c='); readln(c); delta:=(b*b-4*a*c); if delta
  2. begin x:=-b/(2*a); writeln('co nghiem kep x=',x:8:3); end; if delta>0 then begin x1:=(-b+sqrt(delta))/(2*a); x2:=(-b-sqrt(delta))/(2*a); writeln('x1=',x1:8:3); writeln('x2=',x2:8:3); end; readln; END. program bt2th1; Var a,b,c,m,n,p,X1,X2:real;
  3. DD,DX,DY:real; BEGIN writeln('nhap gia tri cac he so cua he'); write('a='); readln(a); write('b='); readln(b); write('c='); readln(c); write('m='); readln(m); write('n='); readln(n); write('p='); readln(p); DD:=a*n-m*b; DX:=c*n-b*p; DY:=a*p-c*m; X1:=DX/DD; X2:=DY/DD; if DD=0 then begin if (DX=0) and (DY=0) then
  4. writeln('phuong trinh vo so nghiem') else writeln('phuong trinh vo nghiem'); end else begin Writeln('X1=',X1:8:3); writeln('X2=',X2:8:3); end; readln; END. Program bt3th1; Var a,b,c,Cv,s,p:real;
  5. BEGIN writeln('nhap he so tam giac:'); write('a='); readln(a); write('b='); readln(b); write('c='); readln(c); p:=(a+b+c)/2; s:=sqrt(p*(p-a)*(p-b)*(p-c)); Cv:=a+b+c; if (a+b>c) and (a+c>b) and (b+c>a) and (a>0) and (b>0) and (c>0) then begin writeln('a,b,c la 3 canh tam giac'); writeln('s=',s:3:1); writeln('Cv=',Cv:3:1); end else writeln('Rat tiec so ban nhap ko thoa man !');
  6. readln; END. program bt4th1; var i,n,tc,tl:integer; begin write('nhap gia tri n='); readln(n); tc:=0; tl:=0; for i:= 1 to n do if i mod 2 =0 then tc:=tc+i else
  7. tl:=tl+i; write('tong cac so chan la:',tc:3); write('tong cac so le la:',tl:3); readln; end. program bt5th1; var s:real; i,n:integer; begin writeln('nhap gia tri n='); readln(n); s:=0; for i:= 1 to n do s:=s+1/i; write('tong s=',s:3:1);
  8. readln; end. program bt6th1; var T,i,n:integer; S,x:real; begin write('nhap gia tri n='); readln(n); write('nhap gia tri x='); readln(x); T:=1; S:=0; for i:= 1 to n do begin T:=-1*T; S:=S+(T*x)/i;
  9. end; write('tong s=',s:5:2); readln; end. program bt7th1; var a,b,c:integer; begin for a:= 1 to 9 do for b:= 0 to 9 do for c:= 0 to 9 do if 100*a+10*b+c= a*a*a+b*b*b+c*c*c then writeln(a,b,c); readln; end.
  10. program bt8th1; var x,y,z:integer; begin for x:= 0 to 20 do for y:= 0 to 33 do for z:= 0 to 100 do if (5*x+3*y+z/3=100) and (x+y+z =100) then writeln(x:3,y:3,z:3); readln; end.
  11. program bt9th1; var n:integer; begin repeat write('nhap gia tri n='); readln(n); writeln('so ban nhap la:'); until (n>=0) and (n
  12. 7:write('so bay'); 8:write('so tam'); 9:write('so chin'); end; readln; end. program bt10th1; var a,b,t:integer; begin repeat write('Nhap so a='); readln(a); write('Nhap so b='); readln(b); until (a>0) and (b>0); repeat t:=b;
  13. b:=a mod b; a:=t; until b=0; write('USCLN hai so a va b la:',a:2); readln; end. program bt11th1; var a,b,t,x,y:integer; bscnn: integer; begin repeat write('Nhap so a='); readln(a); x:=a; write('Nhap so b='); readln(b); y:=b;
  14. until (a>0) and (b>0); repeat t:=b; b:=a mod b; a:=t; until b=0; writeln('USCLN hai so a va b la:',a:2);; bscnn:=trunc((x*y)/a); writeln('BSCNN hai so a va b la:',bscnn:3); readln; end. program bt12th1; var n,i:integer; begin
  15. writeln('TRUONG TRINH KIEM TRA SO NGUYEN TO'); write('nhap so n muon kiem tra:'); readln(n); for i:= 2 to trunc(sqrt(n)) do if n mod i 0 then write('La so nguyen to ') else write('Khong la so nguyen to'); readln; end. program bt13th1; var i:integer; s,n:real; begin writeln('dan so nam 1990 la: 65 trieu'); s:=65; i:=0; n:=65; while s
  16. begin s:=s+s*2/100; i:=i+1; end; writeln('sau ',i,' nam dan so nuoc nay la 95 trieu'); for i:=1 to 19 do n:=n+n*2/100; writeln('nam 2009 dan so nuoc nay la ',n:5:2,' trieu'); readln; end. program bt14th1; var s,n,x:integer; begin write('nhap so x= '); readln(x); repeat
  17. n:=n+1; s:=s+1; until s>=x; writeln('so lon nhan thoa man la:',n-1:2); readln; end. program b15p1; var i,d:integer; s:real; a:array[1..20] of integer; begin writeln('nhap vao cac gia tri cua day so'); d:=0; repeat inc(d); write('nhap a[',d,']: '); readln(a[d]); until a[d]=0; s:=0; for i:=1 to d-1 do s:=s+a[i];
  18. writeln('trung binh cong cac so vua nhap: ',s/(d-1):3:2); readln; end. Program BT15TH1; var i,d:integer; s:real; a:array[1..20] of integer; begin writeln('nhap vao cac gia tri cua day so'); d:=0; repeat inc(d); write('nhap a[',d,']: '); readln(a[d]); until a[d]=0; s:=0;
  19. for i:=1 to d-1 do s:=s+a[i]; writeln('trung binh cong cac so vua nhap: ',s/(d-1):3:2); readln; end. Thuc hanh 2 program bt1th2; var i,x,n,d:integer; a:array [1..20] of integer; begin write('cho so phan tu n='); readln(n); writeln('nhap gia tri cac phan tu cua day'); for i:= 1 to n do
  20. begin write('a[',i,']='); readln(a[i]); end; writeln('day so vua nhap la'); for i:= 1 to n do write(a[i]:7); writeln; write('nhap so x='); readln(x); d:=0; for i:=1 to n do if a[i]= x then begin d:=d+1; end; write('co ',d,' so bang so x'); writeln; write('vi tri cua chung la'); for i:=1 to n do
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2