Tin Hoc

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Tin Hoc as PDF for free.

More details

  • Words: 2,077
  • Pages: 8
®Ò c¬ng tin häc phÇn lý thuyÕt C©u 1: h·y cho biÕt c¸ch khai b¸o biÕn sè nguyªn n , lÖnh in sè nguyªn n cã quy c¸ch . +)môc khai b¸o biÕn b¾t ®Çu b»ng tõ kho¸ VAR , sau ®ã lµ c¸c lÖnh khai b¸o biÕn . Quy c¸ch: VAR : ; VD: VAR N:integer ; +)lÖnh in sè nguyªn n cã quy c¸ch < biÓu thøc kiÓu IN >: n VD: VAR I,J :integer ; Begin Writeln( ‘ 12345678901234567890 ‘) ; I := 123 ; J := 456 ; Writeln( I ) ; (®a ra kh«ng quy c¸ch ) Writeln( J : 8 ) ; (®a ra cã quy c¸ch ) End. C©u 2 : h·y cho biÕt c¸ch khai b¸o biÕn sè thùc x , lÖnh in sè thùc x cã quy c¸ch . +) Quy c¸ch: VAR : ; VD: VAR X : real ; +)lÖnh in sè thùc x cã quy c¸ch < biÓu thøc kiÓu RE >: n :m VD: VAR R : real ; Begin Writeln( ‘ 12345678901234567890 ‘) ; R := 123 . 456 ; Writeln( R ) ; (®a ra kh«ng quy c¸ch ) Writeln( R : 12 : 6 ) ; (®a ra cã quy c¸ch ) End. C©u 3 : h·y cho biÕt c¸ch khai b¸o biÕn kÝ tù ch , lÖnh in kÝ tù ch cã quy c¸ch . +) Quy c¸ch:

VAR : ; VD: VAR Tr¶ lêi : char ; +)lÖnh in kÝ tù ch cã quy c¸ch < biÓu thøc kiÓu CH >: n VD: Writeln( ‘ 123456789 ‘) ; Writeln( ‘ A ‘ ) ; (®a ra kh«ng quy c¸ch ) Writeln( ‘ B ‘ : 8 ) ; (®a ra cã quy c¸ch ) C©u 4 : h·y cho biÕt c¸ch khai b¸o mét x©u kÝ tù st , lÖnh in x©u kÝ tù st cã quy c¸ch . +) Quy c¸ch: VAR : ; VD: VAR Hä vµ tªn : string [25 ] ; Líp : string [25 ] ; +)lÖnh in x©u kÝ tù cã quy c¸ch < biÓu thøc kiÓu ST>: n VD: VAR Tªn 1 , tªn 2 : string [25 ] ; begin Writeln( ‘ 1234567890123456789012345 ‘) ; Tªn 1 := ‘ son ‘ ; Tªn 2 := ‘ ha ‘ ; Writeln( ten 1) ; (®a ra kh«ng quy c¸ch ) Writeln( ten 2 : 25) ; (®a ra cã quy c¸ch ) End. C©u 5 : h·y cho biÕt ( c¸c ) lÖnh nhËp 1 sè nguyªn n . +) Quy c¸ch: Read ( ) ; Readln ( ) ; Readln ; C©u 6 : h·y cho biÕt ( c¸c ) lÖnh nhËp 2 sè thùc a , b . +) Quy c¸ch: Write ( < dßng nh¾c > ) ; Readln ( ) ; Vd : write (‘ cho biÕt a = ‘ ) ; readln (a ) ; write (‘ cho biÕt b = ‘ ) ; readln (b ) ; c©u 7 : h·y cho biÕt ( c¸c ) lÖnh nhËp 1 x©u kÝ tù +) Quy c¸ch: Write ( < dßng nh¾c > ) ; Readln ( ) ;

Vd : write ( ‘ nh©p tªn c«ng nh©n : ‘ ) ; readln (tªn ) ; C©u 8 : h·y cho biÕt ( c¸c ) lÖnh lÆp tÝnh tæng n sè tù nhiªn ®Çu tiªn (c¸c c¸ch kh¸c nhau) C1 : dïng IF……….THEN C2 : dïng FOR…TO…….DO C3 : dïng FOR……DOWNTO….DO C4 : dïng WHILE……….DO C©u 9 : h·y cho biÕt ( c¸c ) lÖnh lÆp tÝnh tÝch n sè tù nhiªn ®Çu tiªn (c¸c c¸ch kh¸c nhau) C1 : dïng IF……….THEN C2 : dïng FOR…TO…….DO C3 : dïng FOR……DOWNTO….DO C4 : dïng WHILE……….DO C©u 10 : h·y cho biÕt ( c¸c ) lÖnh lÆp thùc hiÖn c«ng viÖc 1 khi chØ biÕt ®iÒu kiÖn lÆp (c¸c c¸ch kh¸c nhau) ( IF ……. THEN ) Quy c¸ch 1 : IF THEN < c©u lÖnh 1 > ; Quy c¸ch 2 : IF THEN < c©u lÖnh 1 > ELSE < c©u lÖnh 2 > ; ( FOR …….. DO ) Quy c¸ch 1: FOR < biÕn > := < gi¸ trÞ ®Çu > TO DO ; Quy c¸ch 2: FOR < biÕn > := < gi¸ trÞ ®Çu >DOWN TO DO ; C©u 11 : h·y cho biÕt ( c¸c ) lÖnh ®iÒu khiÓn chia 2 nh¸nh ( IF ……. THEN ) Quy c¸ch 1 : IF THEN < c©u lÖnh 1 > ; Quy c¸ch 2 : IF THEN < c©u lÖnh 1 > ELSE < c©u lÖnh 2 > ; ( GOTO ) Quy c¸ch : GOTO ; ( CASE ……….. OF ) Quy c¸ch 1 : Case < biÓu thøc > of < gi¸ trÞ 11 > , : < c©u lÖnh 1 > ; < gi¸ trÞ 21 >.. : < c©u lÖnh 2 > ;

… < gi¸ trÞ n >:

< c©u lÖnh n > ;

End; Quy c¸ch 2 : Case < biÓu thøc > of < gi¸ trÞ 11 > , : < c©u lÖnh 1 > ; < gi¸ trÞ 21 >.. : < c©u lÖnh 2 > ; … < gi¸ trÞ n >:

< c©u lÖnh n > ; Else < c©u lÖnh n+1 > ; End ; ( WHILE ……….DO) Quy c¸ch WHILE < biÓu thøc logic > DO < c©u lÖnh > ( REPEAT………..UNTIL ) Quy c¸ch Repeat < c©u lÖnh 1 > ; .. < c©u lÖnh n > ; UNTIL < biÓu thøc logic > ; C©u 12 : h·y cho biÕt ( c¸c ) lÖnh ®iÒu khiÓn thùc hiªn c«ng viÖc 1 khi tho¶ m·n ®iÒu kiÖn 1 ( IF ……. THEN ) Quy c¸ch 1 : IF THEN < c©u lÖnh 1 > ; Quy c¸ch 2 : IF THEN < c©u lÖnh 1 > ELSE < c©u lÖnh 2 > ; ( FOR …….. DO ) Quy c¸ch 1: FOR < biÕn > := < gi¸ trÞ ®Çu > TO DO ; Quy c¸ch 2: FOR < biÕn > := < gi¸ trÞ ®Çu >DOWN TO DO ; C©u 13 : h·y cho biÕt hµm tÝnh ®é dµi x©u kÝ tù x ( IF ……. THEN ) Quy c¸ch 1 : IF THEN < c©u lÖnh 1 > ; Quy c¸ch 2 : IF THEN

< c©u lÖnh 1 > ELSE < c©u lÖnh 2 > ; ( FOR …….. DO ) Quy c¸ch 1: FOR < biÕn > := < gi¸ trÞ ®Çu > TO DO ; Quy c¸ch 2: FOR < biÕn > := < gi¸ trÞ ®Çu >DOWN TO DO ; C©u 14 :h·y cho biÕt (c¸c ) lÖnh ®Ó in mét x©u kÝ tù x theo thø tù ngîc l¹i ( IF ……. THEN ) Quy c¸ch 1 : IF THEN < c©u lÖnh 1 > ; Quy c¸ch 2 : IF THEN < c©u lÖnh 1 > ELSE < c©u lÖnh 2 > ; ( FOR …….. DO ) Quy c¸ch 1: FOR < biÕn > := < gi¸ trÞ ®Çu > TO DO ; Quy c¸ch 2: FOR < biÕn > := < gi¸ trÞ ®Çu >DOWN TO DO ; C©u 15 :h·y cho biÕt (c¸c )lÖnh ®Ó in kÝ tù cuèi cïng cña x©u ®ã (c¸c c¸ch kh¸c nhau ) ( IF ……. THEN ) Quy c¸ch 1 : IF THEN < c©u lÖnh 1 > ; Quy c¸ch 2 : IF THEN < c©u lÖnh 1 > ELSE < c©u lÖnh 2 > ; ( FOR …….. DO ) Quy c¸ch 1: FOR < biÕn > := < gi¸ trÞ ®Çu > TO DO ; Quy c¸ch 2: FOR < biÕn > := < gi¸ trÞ ®Çu >DOWN TO DO ; C©u 16 :h·y cho biÕt (c¸c )lÖnh ®Ó in mét x©u kÝ tù x cho tríc gåm toµn c¸c ch÷ in ( IF ……. THEN ) Quy c¸ch 1 : IF THEN

< c©u lÖnh 1 > ; Quy c¸ch 2 : IF THEN < c©u lÖnh 1 > ELSE < c©u lÖnh 2 > ; ( FOR …….. DO ) Quy c¸ch 1: FOR < biÕn > := < gi¸ trÞ ®Çu > TO DO ; Quy c¸ch 2: FOR < biÕn > := < gi¸ trÞ ®Çu >DOWN TO DO ; C©u 17 : h·y cho biÕt ( c¸c ) lÖnh ®iÒu khiÓn thùc hiªn c«ng viÖc 1 vµ c«ng viÖc 2 khi tho¶ m·n ®iÒu kiÖn 1 , thùc hiÖn c«ng viÖc 3 khi tho¶ m·n ®iÒu kiÖn 2 ( IF ……. THEN ) Quy c¸ch 1 : IF THEN < c©u lÖnh 1 > ; Quy c¸ch 2 : IF THEN < c©u lÖnh 1 > ELSE < c©u lÖnh 2 > ; ( FOR …….. DO ) Quy c¸ch 1: FOR < biÕn > := < gi¸ trÞ ®Çu > TO DO ; Quy c¸ch 2: FOR < biÕn > := < gi¸ trÞ ®Çu >DOWN TO DO ; C©u 18: h·y lËp ch¬ng tr×nh con lµ hµm tÝnh giai thõa cña sè n ( c¸c c¸ch kh¸c nhau ) C1: uses crt; var n,s,i,j,t:integer; BEGIN clrscr;write('nhap n=');readln(n); for i:=1 to n do begin t:=1; for j:=1 to i do T:=T*j; writeln(i:2,'!=',T:3); S:=s+t; end; write('S=1!+2!+...+',n:2,'!=',s:4); readln END.

C2: uses crt; var n,s,i,j,m,a,t:integer;tl:char; BEGIN clrscr;write('nhap n=');readln(n); for i:=1 to n do begin t:=1; for j:=1 to i do T:=T*j; writeln(i:2,'!=',T:3); S:=s+t; end; write('S=1!+2!+...+',n:2,'!=',s:4); readln END. C3: uses crt; var i,n:integer;T,S:longint; BEGIN clrscr; T:=1; write('nhap n= ');readln(n); for i:=1 to n do begin T:=T*i; S:=S+T; end; write('1!+2!+...+',n:2,'!=',S); readln END. C4: Uses Crt; Var i,n:integer;s,sh:real; BEGIN Clrscr; Write('Nhap n=');readln(n);sh:=1; for i:=1 to n do begin sh:=sh*1/i;s:=s+sh;writeln(sh:5:3);end; write('Tong 1/1!+1/2!+...+1/',n:2,'!=',s:5:3); Readln End. C©u 19 : h·y lËp ch¬ng tr×nh con lµ thñ tôc nhËp 2 sè thùc a,b Program nhap ; Uses crt ; Var a, b : real ; Begin Clrscr ; Write ( ‘ cho biet a = ‘ ) ; readln ( a ) ;

Write ( ‘ cho biet b = ‘ ) ; readln (b ) ; Writeln ( cho biet a, b :8 :2 ) ; Readln End . C©u 20 : h·y lËp ch¬ng tr×nh ®Ó nhËp tªn 1 häc sinh , trai hay g¸i ( nÕu trai gâ t , g¸I gâ G ) , ®iÓm thi m«n tin häc ( 1 sè lÎ ) , råi in kÕt qu¶ díi d¹ng : häc sinh (tªn) lµ (trai hay G¸I ) , ®¹t (sè ®iÓm ) ®iÓm program nhapten; uses crt; var ht :string [20] ;gt, dt : real ; begin clrscr ; write ('cho biet ho va ten ');readln(ht); write (' cho biet diem thi '); readln (dt); write(' cho biet gioi tinh neu la trai nhap 1 neu la gai nhap 0 ');readln( gt); begin if gt=1 then writeln (' gioi tinh la T ') else writeln ('gioi tinh la G '); end; writeln ('ho ten ' ,ht); writeln(' diem thi la ' ,dt:6:1); readln end.

Related Documents

Tin Hoc
June 2020 10
Tin Hoc Dai Cuong
November 2019 36
Bai Thi Tin Hoc
April 2020 16
Trang Web Tin Hoc
November 2019 7
Bai Tap Tin Hoc
June 2020 12
Tkggiangto Tin Hoc
June 2020 2