29.06.2020 Views

Bài tập Pascal Free Pascal 01 đến 16 Có bài giải (từ đơn giản đến nâng cao) BY Nguyễn Anh Việt

https://app.box.com/s/mtg0fzik6bet3tes96tu4bmt8wsxaahw

https://app.box.com/s/mtg0fzik6bet3tes96tu4bmt8wsxaahw

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Bài tập Pascal – Từ cơ bản đến nâng cao

Var

So, LT, STP: LongInt;

CTLP: String;

Begin

WriteLn('Hay nhap chuoi so can doi tu he 16 sang he 10');

ReadLn(CTLP);

LT:=1;

For i:= Length(CTLP) downto 1 do Begin

If CTLP[i] = '0' then So := 0

Else If CTLP[i] = '1' then So:= 1

Else If CTLP[i] = '2' then So:= 2

Else If CTLP[i] = '3' then So:= 3

Else If CTLP[i] = '4' then So:= 4

Else If CTLP[i] = '5' then So:= 5

Else If CTLP[i] = '6' then So:= 6

Else If CTLP[i] = '7' then So:= 7

Else If CTLP[i] = '8' then So:= 8

Else If CTLP[i] = '9' then So:= 9

Else If CTLP[i] = 'A' then So:= 10

Else If CTLP[i] = 'B' then So:= 11

Else If CTLP[i] = 'C' then So:= 12

Else If CTLP[i] = 'D' then So:= 13

Else If CTLP[i] = 'E' then So:= 14

Else If CTLP[i] = 'F' then So:= 15 ;

STP := STP + So * LT;

LT := LT * 16;

End;

WriteLn('Chuoi ', CTLP, ' trong he 16 doi sang he 10 la ', STP);

ReadLn;

End.

Bài tập 11.03 – Đổi chuổi số theo hệ m (m từ 2 đến 16) thành số thập phân:

Var

m: Integer;

So, LT, STP: LongInt;

Ch: String;

Begin

WriteLn('Hay nhap chuoi so can doi tu he m sang he thap phan');

ReadLn(Ch);

WriteLn('Hay nhap he m (2 den 16)');

ReadLn(m);

LT:=1;

For i:= Length(Ch) downto 1 do Begin

If CH[i] = '0' then So := 0

Biên soạn: Th.s Nguyễn Anh Việt Trang 40

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!