Tin học Phần mền chuyển đổi cơ số từ cơ số 10 viết bằng pascal

dangxuanchuon

Học sinh
Thành viên
31 Tháng bảy 2022
140
96
46
Phú Yên
[TẶNG BẠN] TRỌN BỘ Bí kíp học tốt 08 môn
Chắc suất Đại học top - Giữ chỗ ngay!!

ĐĂNG BÀI NGAY để cùng trao đổi với các thành viên siêu nhiệt tình & dễ thương trên diễn đàn.

code:
Mã:
program chuyen_doi_he_co_so_tu_10;
uses crt;
var n, r: Int64;
m, i, j: byte;
a: array[1..64] of byte;
const max = 64;
begin;
clrscr;
delay(1000);
m := 0;
while m = 0 do
        begin
        write('     Nhap so ban dau: ');
        readln(n);
        write('   nhap he co so ban muon chuyen sang: ');
        readln(m);
        if (m>1) and (m<=max) then
                begin
                r:=abs(n);
                i:=1;
                while r > 0 do
                        begin
                        a[i]:= r mod m;
                        r:= r div m;
                        i:=i+1;
                        end;
                i:=i-1;
                write('    ');
                if n<0 then write('-');
                if n=0 then write('    0, chan lam');
                while i>0 do
                        begin
                        if a[i]<10 then write(a[i]);
                        if a[i]=10 then write('A');
                        if a[i]=11 then write('B');
                        if a[i]=12 then write('C');
                        if a[i]=13 then write('D');
                        if a[i]=14 then write('E');
                        if a[i]=15 then write('F');
                        if a[i]=16 then write('G');
                        if a[i]=17 then write('H');
                        if a[i]=18 then write('I');
                        if a[i]=19 then write('J');
                        if a[i]=20 then write('K');
                        if a[i]=21 then write('L');
                        if a[i]=22 then write('M');
                        if a[i]=23 then write('N');
                        if a[i]=24 then write('O');
                        if a[i]=25 then write('P');
                        if a[i]=26 then write('Q');
                        if a[i]=27 then write('R');
                        if a[i]=28 then write('S');
                        if a[i]=29 then write('T');
                        if a[i]=30 then write('U');
                        if a[i]=31 then write('V');
                        if a[i]=32 then write('W');
                        if a[i]=33 then write('X');
                        if a[i]=34 then write('Y');
                        if a[i]=35 then write('Z');
                        if a[i]=36 then write('a');
                        if a[i]=37 then write('b');
                        if a[i]=38 then write('c');
                        if a[i]=39 then write('d');
                        if a[i]=40 then write('e');
                        if a[i]=41 then write('f');
                        if a[i]=42 then write('g');
                        if a[i]=43 then write('h');
                        if a[i]=44 then write('i');
                        if a[i]=45 then write('j');
                        if a[i]=46 then write('k');
                        if a[i]=47 then write('l');
                        if a[i]=48 then write('m');
                        if a[i]=49 then write('n');
                        if a[i]=50 then write('o');
                        if a[i]=51 then write('p');
                        if a[i]=52 then write('q');
                        if a[i]=53 then write('r');
                        if a[i]=54 then write('s');
                        if a[i]=55 then write('t');
                        if a[i]=56 then write('u');
                        if a[i]=57 then write('v');
                        if a[i]=58 then write('w');
                        if a[i]=59 then write('x');
                        if a[i]=60 then write('y');
                        if a[i]=61 then write('z');
                        if a[i]=62 then write('+');
                        if a[i]=63 then write('/');
                        if a[i]>63 then
                                begin
                                delay(1000);
                                Textcolor(red);
                                write(' ',a[i],'?! ');
                                Textcolor(white);
                                delay(1000);
                                end;
                        i:=i-1;
                        end;
                writeln;
                end
        else writeln('  no!');
        Write('   tiep tuc? muon chon 0, khong chon so khac: ');
        readln(m);
        end;
writeln('ok...');
delay(1000);
end.
một số chú ý:
-số cần đổi phải trong khoảng -9 223372036 854775808 tới 9 223372036 854775807 (± 9 tỉ tỉ hay 19 chữ số)
-bắt đầu từ hệ cơ số 10
-hệ cớ số cuối phải không đc lớn hơn 64 -tất cả định dạng cần nhập chỉ nhập ở dạng số tự nhiên (toàn bộ kí tự là từ 0,1,2,3,4,5,6,7,8,9 và - ở đầu số, không cách)
-cách dán code: https://diendan.hocmai.vn/threads/cach-dan-code-vao-trong-pascal.686564/ (đã đọc nội quy)
-dòng dưới đúng
-dòng trên sai
 
Top Bottom