Kết quả 1 đến 2 của 2
  1. #1
    Ngày tham gia
    Nov 2015
    Bài viết
    0

    nhờ mấy bạn giúp

    may ban giup mjnh máy bài này
    bài 1: viết chương trình tính a^x bằng 2 cách đệ quy và khử đệ quy
    bài 2:cài đặt danh sách sinh viên có mã số sv,họ tên,điểm sv,và thưc hiện các thông tin trên danh sách chèn vào 1 phần tử x ở vị trí thứ k.hiển thị danh sách
    xóa một phần tử tại vị trí thứ k

  2. #2
    Ngày tham gia
    Feb 2016
    Bài viết
    5
    ec

    chương trình này bạn tham khảo cho ý kiến he!



    program sgk;
    uses crt;
    type ds=^nguoi;
    nguoi=record
    mhs:byte;
    hoten:string[25];
    diem:real;
    tiep:ds;
    end;
    var dslop,ctdau,ctcuoi:ds;
    lam:char;
    i,j,n:byte;
    procedure xem;
    var ct1:ds;
    begin
    clrscr;
    ct1:=ctdau;
    writeln('du lieu da ngap_hien tu dau xuong cuoi');
    writeln;
    ct1:=ctdau;
    while ct1<>nil do
    with ct1^ do
    begin
    write(mhs,' ',hoten);
    for i:=1 to 20-length(hoten) do write(' ');
    writeln(diem:5:2);
    ct1:=tiep;
    end;
    readln;
    end;
    {--------------------------------------------------------}
    procedure nhap;
    begin
    clrscr;
    ctdau:=nil; j:=0;
    repeat
    new(dslop);
    j:=j+1;
    with dslop^ do
    begin
    writeln;
    writeln;
    writeln('ma ho so :',j); mhs:=j;
    write('ho va ten : '); readln(hoten);
    write('diem :'); readln(diem);
    if ctdau=nil then
    ctdau:=dslop
    else ctcuoi^.tiep:=dslop;
    ctcuoi:=dslop;
    ctcuoi^.tiep:=nil;
    writeln;
    writeln;
    writeln(' nhap tiep hay thoi c/k '); lam:=readkey;
    writeln;
    end;
    until lam in['k','K'];
    end;
    {-------------------------------------------------------}
    procedure chen;
    var n:byte; ct1:ds;
    begin
    clrscr;
    writeln(' chen truoc ma ho so nao ? '); readln(n);
    new(ct1);
    with ct1^ do
    begin
    write(' ho va ten '); readln(hoten);
    write('dien :'); readln(diem);
    end;
    dslop:=ctdau;
    while(dslop<>nil) and (dslop^.mhs<>n) do dslop:=dslop^.tiep;
    ct1^.tiep:=dslop^.tiep;
    dslop^.tiep:=ct1;
    end;
    {----------------------------------------------}
    procedure xoa;
    var n:string[25]; ct1:ds;
    begin
    clrscr;
    write(' cho biet ten nguoi can xoa ?'); readln(n);
    dslop:=ctdau;
    while (dslop<>nil)and(dslop^.hoten<>n) do
    begin
    ct1:=dslop;
    dslop:=dslop^.tiep;
    end;
    if dslop=ctdau then ctdau:=dslop^.tiep
    else
    ct1^.tiep:=dslop^.tiep;
    dispose(dslop);
    end;
    {--CHUONG TRINH CHINH---}
    BEGIN
    repeat
    clrscr;
    writeln('1: nhap du lieu ');
    writeln('2: xem danh sach');
    writeln('3: chen them phan tu');
    writeln('4: xoa phan tu');
    writeln('5: thoat chuong trinh');
    write(' ban chon cong viec'); readln(n);
    case n of
    1:nhap;
    2:xem;
    3:chen;
    4:xoa;
    5:exit;
    end;
    until 1=2;
    end.

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •