1. Trang chủ
  2. » Giáo án - Bài giảng

BT TIN HOC

14 89 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Program Doi_do_F_C; Var f,c:Real; Begin Writeln('DOI DO FAHRENHEIT SANG CELCIUS'); Write('-Cho biet do Fahrenheit : '); Readln(f); c:=((f-32) * 5)/9; Writeln; Writeln(f:5:2,' do Fahrenheit doi sang do Celcius = ',c:5:2,#248); Writeln; Writeln(' Bam phim de ket thuc'); Readln End. Program Tinh_a_mu_b; Var a,b:Integer; p:Real; Begin Writeln('TINH TRI CUA A MU B'); Writeln(' '); Writeln; Write('-Nhap so nguyen A: '); Readln(a); Write('-Nhap so mu B : '); Readln(b); P:=Exp(b * Ln(a)); Writeln('*Tri A mu B = ',p:10:2); Writeln(' Bam phim de ket thuc'); Readln End. Program Tong_bac_ba; Var k,n:Byte; s:Longint; Begin Writeln('TINH TONG BAC 3 CUA N SO NGUYEN DAU TIEN'); Writeln(' '); Write('-Nhap so N= '); Readln(n); S:=0; For k:=1 To N Do S:=S+(k*k*k); Writeln('+Tong bac 3 cua ',n,' so nguyen dau tien = ',s); Writeln; Writeln(' Bam phim de ket thuc'); Readln End. Program uoc_so; Var i,n:Integer; Begin Writeln('TIM CAC UOC SO CUA SO NGUYEN'); Writeln(' '); Write('-Nhap mot so nguyen: '); Readln(n); Writeln; Writeln('+Cac uoc so cua so ',n,' la: '); Writeln; For i:=1 To N Do If (n Mod i) = 0 Then Write(i:6); Writeln; Writeln; Writeln(' Bam phim de ket thuc'); Readln End. Program Tam_giac_can; Var cao,i,j:Byte; Begin Writeln(' TAM GIAC CAN DAC'); Writeln('Chieu cao gioi han tu 1 den 22'); Writeln(' '); Write('-Nhap chieu cao: '); Readln(cao); For i:=1 To cao Do Begin Write(#32:cao-i+1); For J:=1 To (2*i-1) Do Write('*'); Writeln; End; Writeln; Writeln(' Bam phim de ket thuc'); Readln End. Program Tinh_giai_thua; Var n,i:Integer; gt:LongInt; Begin Writeln('TINH N!'); Writeln(' '); Write('-Nhap N= '); Readln(n); gt:=1; For i:=1 To n Do gt:=gt*i; Writeln; Writeln('+Giai thua cua ',n,' = ',gt); Writeln; Writeln(' Bam phim de ket thuc'); Readln End. Program Dem_chu; Var chuoi:String; i,dem,dai:Byte; Begin Writeln('DEM CHU ''ng'' TRONG CHUOI'); Writeln(' '); Write('-Nhap mot chuoi bat ky: '); Readln(chuoi); dem:=0; dai:=length(chuoi); For i:=1 To dai Do If chuoi[i]+chuoi[i+1]='ng' Then inc(dem); Writeln; Writeln('Trong cau: ','" ',chuoi,' "'); Writeln('Co ',dem,' lan xuat hien chu ''ng'''); Writeln; Writeln(' Bam phim de ket thuc'); Readln End. Program So_nguyen_to; Var n,i:Integer; Begin Writeln('SO VUA NHAP CO PHAI LA SO NGUYEN TO ?'); Writeln(' '); Write('-Nhap mot so : '); Readln(n); While n > 1 Do Begin i:=2; While (n Mod i <> 0) Do i:=i+1; if i=n Then Writeln('-So ',n,' la so nguyen to') Else Writeln('-So ',n,' khong phai la so nguyen to'); Write('-Nhap mot so (so 0 de ngung): '); Readln(n); End; Writeln; Writeln(' Bam phim de ket thuc'); Readln End. Program Day_so_Fibonaci; Var n,j,pj,pj1,pj2:Integer; Begin Writeln('IN DAY SO FIBONACI'); Writeln(' '); Write('-Nhap so N= '); Readln(n); j:=2; pj:=1; pj1:=1; While j <> n Do Begin pj2:=pj1; pj1:=pj; pj:=pj1+pj2; j:=j+1; End; Writeln; Writeln('+So hang thu ',n,' cua day Fibonaci = ',pj); Writeln; Writeln(' Bam phim de ket thuc'); Readln End. Program Luy_thua; Var x,n,tich,luythua:Integer; Begin Writeln('TINH TRI CUA X LUY THUA N'); Writeln(' '); Write('-Nhap vao so X= '); Readln(x); Write('-Nhap vao luy thua N= '); Readln(n); tich:=1; luythua:=1; While luythua <= n Do Begin tich:=tich * x; luythua:=luythua + 1; End; Writeln; Writeln(x,' luy thua ',n,' = ',tich); Writeln; Writeln(' Bam phim de ket thuc'); Readln End. Program cat_chuoi; Var chuoi,tam:String; Begin Writeln('CAT CHUOI THANH TUNG TU'); Writeln(' '); Write('-Nhap mot chuoi: '); Readln(chuoi); While chuoi <> '' Do Begin While chuoi[1] = #23 Do chuoi:=copy(chuoi,2,255); If pos(#32,chuoi) <> 0 Then tam:=copy(chuoi,1,pos(#32,chuoi)) Else tam:=chuoi; Writeln(tam); Delete(chuoi,1,length(tam)); End; Writeln; Writeln(' Bam phim de ket thuc'); Readln End. Program thua_so_nguyen_to; Var n,i:Integer; Begin Writeln('PHAN TICH N THANH TICH CAC THUA SO NGUYEN TO'); Writeln(' '); Write('-Nhap so N= '); Readln(n); Repeat i:=2; While (n Mod i <> 0) And (i < n ) Do i:=i + 1; Write(i:4); n:=n Div i; Until n=1; Writeln; Writeln(' Bam phim de ket thuc'); Readln End. Program PTB2; Var a,b,c,delta : Integer; x1,x2:Real; Begin Writeln('GIAI PHUONG TRINH BAC 2'); Writeln('Bat buoc he so a <> 0'); Writeln(' '); Repeat Write('-Nhap he so a= '); Readln(a); Until a<>0; Write('-Nhap he so b= '); Readln(b); Write('-Nhap he so c= '); Readln(c); delta:=b*b - 4*a*c; If Delta < 0 Then Writeln('+Phuong trinh vo nghiem') Else If delta = 0 Then Writeln('+Phuong trinh co 2 nghiem bang nhau X= ',-b/(2*a):6:2) Else Begin Writeln('Phuong trinh co 2 nghiem phan biet'); Writeln('+X1 = ',(-b+sqrt(delta))/(2*a):6:2); Writeln('+X2 = ',(-b-sqrt(delta))/(2*a):6:2); End; Writeln; Writeln(' Bam phim de ket thuc'); Readln End. Program ma_ASCII; Var kytu:Char; Begin Writeln('MA ASCII CUA KY TU'); Writeln(' '); Repeat Write('-Nhap mot ky tu (bam so 0 de ket thuc) '); Readln(kytu); Writeln('+Ky tu ',kytu,' co ma ASCII = ',ord(kytu)); Writeln; Until kytu='0'; Writeln; Writeln(' Bam phim de ket thuc'); Readln Program Tim_so_nguyen_to; Var n,i,j:Integer; nguyento:Boolean; Begin Writeln('TIM CAC SO NGUYEN TO TU 2 DEN N'); Writeln(' '); Write('-Nhap so N= '); Readln(n); For i:=2 To n Do Begin nguyento:=True; j:=2; While nguyento And (j Begin If (i Mod j)=0 Then nguyento:=False; j:=j+1; End; If nguyento Then Write(i:4); End; Writeln; Writeln(' Bam phim de ket thuc'); Readln End. Program Bang_cuu_chuong; Var i,j:Integer; Begin Writeln(' BANG CUU CHUONG'); Writeln(' '); For i:=1 To 9 Do For j:=1 To 5 Do Write(j:2,' lan ',i:2,' = ',j*i:2,' '); Writeln; Writeln(' '); For i:=1 To 9 Do For j:=6 To 10 Do Write(j:2,' lan ',i:2,' = ',j*i:2,' '); Writeln(' '); Writeln; Write(' Bam phim de ket thuc'); Readln End. Program ga_cho; Var x,y,n:Integer; Begin n:=1; Writeln('* CAC LOI GIAI BAI TOAN CO DIEN GA,CHO'); Writeln(' '); For x:=1 To 36 Do For y:=1 To (36-x) Do If ((x*2)+(y*4) =100) then {and ((x+y) =36) Then} Begin Writeln(' * Loi giai thu : ',n:3); Write('- Ga = ',x:2,' con = ',(x*2):2,' chan '); Write('- Cho = ',y:2,' con = ',(y*4):2,' chan '); If x+y<36 Then Writeln('Ga+Cho= ',x+y:2,' con,khong dung') Else If x+y=36 Then Writeln('Ga+Cho= ',x+y:2,' con,loi giai dung'); n:=n+1; End; Writeln(' * Tong cong co: ',(n-1):3,' loi giai'); Writeln; Writeln(' Bam phim de ket thuc'); Readln End. Program Tram_trau; Var dung,nam,gia,co,trau:Integer; Begin Writeln('BAI TOAN CO DIEN'); Writeln('Tram trau tram co'); Writeln('Trau dung an 5'); Writeln('Trau nam an 3'); Writeln('Ba trau gia an 1'); Writeln(' '); Writeln(' Bai toan nay co cac loi giai sau'); For dung:=0 To 20 Do For nam:=0 To 33-dung Do For gia:=0 To (100-(dung+nam)) Do Begin co:=5*dung+3*nam+(gia Div 3); trau:=dung+nam+gia; If (gia Mod 3 =0) And (trau=100) And ( co=100) Then Writeln('-Trau dung ',dung,' con, -Trau nam ',nam,' con, -Trau gia ',gia,' con'); End; Writeln; Writeln(' Bam phim de ket thuc'); Readln End. Program To_hop_chp_k_cua_N; Var i,k,n:Integer; c:Real; Begin Writeln('TINH TO HOP CHAP k CUA N'); Writeln(' Voi k <= N'); Writeln(' '); Write('-Nhap so N= '); Readln(n); Write('-Nhap so phan tu k= '); Readln(k); If k > N Then Writeln('+Vi k lon hon N nen khong tinh duoc') Else Begin c:=1; For i:=1 To k Do c:=c*(n-k+i)/i; Writeln('+To hop chap ',k,' cua ',n,' la: ',c:2:2); End; Writeln; Writeln(' Bam phim de ket thuc'); Readln End. Program Dao_so; Var n:LongInt; (* *) PROCEDURE Daoso(x:LongInt); Begin Write(x Mod 10); If (x Div 10) <> 0 Then Daoso(x Div 10) End; (* *) BEGIN Writeln('DAO NGUOC MOT SO'); Writeln(' Dung thu tuc'); Writeln(' '); Write('-Nhap mot so nguyen: '); Readln(n); Writeln; Writeln('+So nhap vao la = ',n); Write('+Bay gio la = '); Daoso(n); Writeln; Write(' Bam phim de ket thuc '); Readln END. Program Xo_so; Uses Crt; Var quacau,i:Byte; ch:Char; BEGIN ClrScr; TextColor(Red); Writeln(' QUAY XO SO'); TextColor(Magenta); Writeln(' Su dung ham Random'); TextColor(Yellow); Writeln(' '); Writeln; TextColor(Green); Write(' Cho so qua cau de quay: '); Readln(quacau); Writeln; TextColor(Cyan); Write(' Bam phim bat ky de bat dau quay xo so'); Repeat i:= Random(9); Until KeyPressed; Writeln; TextColor(LightBlue); Write(' Bam phim de ngung quay'); Readln; ch:=ReadKey; Writeln; TextColor(Yellow); Writeln(' KET QUA TRUNG THUONG LA SO: '); Writeln; TextColor(Red); . ',c:5:2,#248); Writeln; Writeln(' Bam phim de ket thuc'); Readln End. Program Tinh_a_mu_b; Var a,b:Integer; p:Real; Begin Writeln('TINH TRI CUA A MU B'); Writeln(' '); Writeln; Write('-Nhap. Do Write('*'); Writeln; End; Writeln; Writeln(' Bam phim de ket thuc'); Readln End. Program Tinh_giai_thua; Var n,i:Integer; gt:LongInt; Begin Writeln('TINH N!'); Writeln(' '); Write('-Nhap N= '); Readln(n); gt:=1; For. ket thuc'); Readln End. Program Tong_bac_ba; Var k,n:Byte; s:Longint; Begin Writeln('TINH TONG BAC 3 CUA N SO NGUYEN DAU TIEN'); Writeln(' '); Write('-Nhap so N=

Ngày đăng: 11/07/2014, 13:00

Xem thêm: BT TIN HOC

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN

w