Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
0 of .
Results for:
P. 1
Bai tap pascal

# Bai tap pascal

Ratings: (0)|Views: 29 |Likes:
Pascal
Pascal

### Availability:

See more
See less

09/21/2014

pdf

text

original

Một số bài tập Pascal
11TYPE mang1=array[1..100] of integer; mang2=array[1..50,1..50] of integer;CONST a:array[0..15] of !ar="#0#,#1#,#2#,#\$#,#%#,#5#,#&#,#'#,#(#,#)#,#*#,#+#,#C#,##,#E#,#-#;/* a, :mang1;:mang2;,i,3,4,f1,f2,min,ma4,t:integer; 6,r,t,y,oe,7o8:integer; f:te4t;9a:array[0..)] of integer;6t:ooean; 7,7t,71,72,a1,1:7tring; fi:ongint;n,m,,<:integer; e4:rea;
begin
{Kiem tra mot day la cap so cong}
write('Nhap n:');readln(n); for i:= to n do begin write('Nhap a!'"i"'#:');readln(a!i#); end; \$t:=tr%e;i:=&; d:=a!&#a!#; while (i=n) do begin if a!i#a!i# *d then \$t:=false; inc(i); end; if \$t then write('da+ la cap so cong') else write(',hong phai la cap so cong')-
{In so nhi phan cua mot so n}

9!ong e <8y>
f%nction nhiphan(n:integer):.tring; /ar i:integer;st:string; begin st:=''; while (n*0) do begin str(n 1od &"s); st:=sst; n:=n di/ &; end; nhiphan:=st; end;
9e <8y>
f%nction de2%+( n:integer):string; /ar s:string; begin if n=0 then de2%+:='' else begin str((n 1od &)"s); de2%+:=de2%+(n di/ &)s; end;

Một số bài tập Pascal
end; begin write('Nhap n:');readln(n); write('3a% nhi phan la '"de2%+(n));
{Dem so 0 co nghia}
9!ong e <8y>
while n*0 do begin if n 1od 0 =0 then inc(d); n:=n di/ 0; end; write('.o ch% so 0 co nghia la'"d);-
9e <8y>
f%nction de2%+(n:longint):b+te; begin if 4(n=0) or (n=) 4 n di/ 0 =0- then de2%+:=0 else if n 1od 0=0 then de2%+:=de2%+(n di/ 0)
9?8 y tr8ong !o 7o 0 8oi 8ng>
else de2%+:=de2%+(n di/ 0); - end;
{Dem so}
9e <8y>
f%nction de2%+(n:integer):integer; begin if n di/ 0=0 then de2%+:= else de2%+:=de2%+(n di/ 0); end;
9!ong e <8y>
begin write('nhap n:');readln(n); d:=0; while n*0 do begin d:=d; n:=n di/ 0; end; write('so co nghia la'"d); readln; end5/ar s:string;n"i"6:integer; a:arra+!5500# of string;
{Xau dao}
f%nction lap(s:string):string;/ar i:integer;st:string; begin st:=''; for i:=length(s) downto  do st:=sts!i#;&

Một số bài tập Pascal
lap:=st;end;f%nction de2%+(s:string):string; begin if length(s) then de2%+:=s else de2%+:=s!length(s)#de2%+(cop+(s""length(s)));end;
{Xau doi xung}
f%nction \$t(s:string):boolean;/ar i:integer;st:string; begin st:='';for i:=length(s) downto  do st:=sts!i#;if st=s then \$t:=tr%eelse \$t:=false;end;f%nction de2%+dao(s:string):boolean; begin if length(s) then de2%+dao:=tr%e else if s!#*s!length(s)# then de2%+dao:=false else begin delete(s""); delete(s"length(s)"); de2%+dao:=de2%+dao(s); end;end; beginwrite('Nhap 7a%:');readln(s);writeln('3a% dao la '"lap(s));writeln('7a% dao la '"de2%+(s));if \$t(s) then writeln('3a% doi 7%ng')else writeln('3a% \$hong doi 7%ng');if de2%+dao(s) then writeln('3a% doi 7%ng')else writeln('3a% \$hong doi 7%ng');-writeln('Nhap so hoc sinh:');readln(n);readln;end5
{Tinh tong p=anxn+an-1xn-1++a!x!+a1x1+a0 hay p=anxn-1++ax+a0 tuy "ao "iec nhap n}
d:=a!n#; for i:=n downto
0
do d:=d87a!i#; write('9ong la'"d);