Diễn Đàn Lớp TK0601 - Huflit
Bạn có muốn phản ứng với tin nhắn này? Vui lòng đăng ký diễn đàn trong một vài cú nhấp chuột hoặc đăng nhập để tiếp tục.
Diễn Đàn Lớp TK0601 - Huflit

Diễn Đàn Lớp TK0601 - Huflit University
 
Trang ChínhTìm kiếmLatest imagesĐăng kýĐăng Nhập

 

 Bài Thi Cấu Trúc Dữ Liệu (2)

Go down 
Tác giảThông điệp
administrator
Bộ Trưởng Quân Đội Cao Cấp - Bộ Chỉ Huy
Bộ Trưởng Quân Đội Cao Cấp - Bộ Chỉ Huy
administrator


Tổng số bài gửi : 348
Age : 36
Location : HCM
Registration date : 08/10/2007

Bài Thi Cấu Trúc Dữ Liệu (2) Empty
Bài gửiTiêu đề: Bài Thi Cấu Trúc Dữ Liệu (2)   Bài Thi Cấu Trúc Dữ Liệu (2) Icon_minitimeWed Nov 21, 2007 4:09 pm

#include<cstdio>
#include <stdlib.h>
#include <conio.h>
#include <string.h>

typedef struct thiSinh
{
char ten[51];
char ma[6];
float dtoan,dly,dhoa,tdiem;
}thiSinh;


struct nut
{
thiSinh tS;
struct nut *tiep;
}nut;

typedef struct nut NUT;
typedef NUT *DSLK;
DSLK dau,cuoi;
DSLK p;

float t,to,l,h;
int n,a;

void taoDS (DSLK&,DSLK&);
void giaiPhong(DSLK &,DSLK &);
void duyetDS(DSLK &);
void themCuoi (DSLK&,DSLK& );
void nhapDL(thiSinh &);
void duyetTS (DSLK &dau);
void duyetDToan (DSLK &dau);


#include"khaiBao.h"
int main()
{
taoDS (dau,cuoi);
duyetDS(dau);
duyetTS (dau);
duyetDToan (dau);
giaiPhong(dau,cuoi);
return 0;
}
void taoDS(DSLK &dau,DSLK & cuoi)
{
thiSinh tS;
dau= cuoi= NULL;
nhapDL( tS);
n=1;
while(n!=0)
{
p=(DSLK)malloc (sizeof(NUT));
p->tS=tS;
p->tiep =NULL;
if (dau==NULL)
{
dau=cuoi=p;
}
else
{
cuoi->tiep=p;
cuoi=p;
}
printf ("\tcon thi sinh khong?( chon 0 neu het)\n");
printf ("\tMoi ban chon :");
scanf ("%d",&n);
if (n!=0)
nhapDL (tS);
}
}
void duyetDS(DSLK &dau)
{
p=dau;
printf ("+--------------------------------+------+------+------+------+---------+\n");
printf ("+ HO VA TEN + MA +toan + ly + hoa +tong diem+\n");
printf ("+--------------------------------+------+------+------+------+---------+\n");
while (p!=NULL)
{
printf ("+%-32s",p->tS.ten);
printf ("+%-6s",p->tS.ma);
printf ("+ %5.2f",p->tS.dtoan);
printf ("+ %5.2f",p->tS.dly);
printf ("+ %5.2f",p->tS.dhoa);
printf ("+%8.2f +\n",p->tS.tdiem);
p=p->tiep;
}
printf ("+--------------------------------+------+------+------+------+---------+");
}
void giaiPhong(DSLK&dau,DSLK&cuoi)
{
p=dau;
while (dau!=NULL)
{
dau=dau->tiep;
free(p);
p=dau;
}
dau=cuoi=NULL;
}
void nhapDL(thiSinh &tS)
{
printf ("nhap ho ten thi sinh ");
fflush (stdin);
gets (tS.ten);
printf ("nhap ma thi sinh ");
gets (tS.ma);
printf ("nhap diem toan ");
scanf ("%f",&t);
tS.dtoan=t;
printf ("nhap diem ly ");
scanf ("%f",&t);
tS.dly=t;
printf ("nhap diem hoa ");
scanf ("%f",&t);
tS.dhoa=t;
tS.tdiem=tS.dtoan+tS.dly+tS.dhoa;
}

void duyetTS(DSLK &dau)
{
p=dau;
printf ("\n\n\t\t CAC THI SINH DAU LA:\n");
while (p!=NULL)
{
t=p->tS.tdiem;
to=p->tS.dtoan;
l=p->tS.dly;
h=p->tS.dhoa;
if ((t>15) & (to!=0) &(l!=0)&(h!=0))
{
printf ("Ho ten thi sinh: %s ,",p->tS.ten);
printf ("co diem la:%f\n",p->tS.tdiem);
}
p=p->tiep;
}
}

void duyetDToan (DSLK & dau)
{
p=dau;
a=0;
printf ("\n");
while (p!=NULL)
{
to=p->tS.dtoan;
if (to>9)
{
printf ("Ho ten thi sinh: %s ,",p->tS.ten);
printf ("co diem toan la:%f\n",p->tS.dtoan);
a=a+1;

}
p=p->tiep;
}
printf ("CO %d THI SINH DIEM TOAN LON HON 9\n",a);
}
Về Đầu Trang Go down
http://www.theuvitinh-hoaidung.co.cc/
administrator
Bộ Trưởng Quân Đội Cao Cấp - Bộ Chỉ Huy
Bộ Trưởng Quân Đội Cao Cấp - Bộ Chỉ Huy
administrator


Tổng số bài gửi : 348
Age : 36
Location : HCM
Registration date : 08/10/2007

Bài Thi Cấu Trúc Dữ Liệu (2) Empty
Bài gửiTiêu đề: Re: Bài Thi Cấu Trúc Dữ Liệu (2)   Bài Thi Cấu Trúc Dữ Liệu (2) Icon_minitimeWed Nov 21, 2007 8:28 pm

đây là bài thi mẫu " Sắp Xếp " , em pé nào xem xong nhớ cho ý kiến nhá ! không là ăn đòn !!! khe...khe ....
Về Đầu Trang Go down
http://www.theuvitinh-hoaidung.co.cc/
 
Bài Thi Cấu Trúc Dữ Liệu (2)
Về Đầu Trang 
Trang 1 trong tổng số 1 trang

Permissions in this forum:Bạn không có quyền trả lời bài viết
Diễn Đàn Lớp TK0601 - Huflit :: Kiến Thức Học Tập :: Kiến Thức Lập Trình :: Chuyên Đề Lập Trình-
Chuyển đến