/////////////////////////////////////////////////////////////////////////////////////////////
// BAI TAP XAY DUNG DANH SACH SINH VIEN //
// //
/////////////////////////////////////////////////////////////////////////////////////////////
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include "iostream"
#include"iomanip"
using namespace std;
/*******************************************************************************************/
struct sinhvien
{
int masv;
char malop[12];
char hovaten[30];
float diemk1;
float diemk2;
};
typedef struct sv
{
sinhvien data;
struct sv*prev;
struct sv*next;
}sv;
/*******************************************************************************************/
struct sv*head; //Con tro toan cuc, giu dia chi cua ca danh sach sinh vien
void nhapdulieutubanphim(); //Ham nhap du lieu truc tiep cho toan danh sach sinh vien
void nhapdulieututep(); //Ham nhap du lieu cho toan danh sach thong qua tep
void nhapdulieutungsvtubanphim(sv*head); //Ham nhap du lieu cho truc tiep tung sinh vien, dong thoi ghi len tep
void nhapdulieutungsvtutep(sv*head,FILE*fvao); //Ham nhap du lieu cho tung sinh vien qua tep
void hienthitoandanhsach(sv*head); //Ham hien thi toan bo danh sach
void hienthidulieutheolop(sv*head); //Ham hien thi STT va ten tung sinh vien thao lop can tim
void timkiem(); //Ham tim liem thong tin sinh vien
void timtheoten(sv*head); // Ham tim kiem theo ten
void timtheomasv(sv*head); //Ham tim kiem theo ma sinh vien
void sapxep(); //Ham sap sep danh sach theo yeu cau,
//cac ham sap xep con deu thuc hien theo thuat toan sap xep chen
void sapxeptheomasv(sv*head); //Ham sap xep theo ma sinh vien
void sapxeptheoten(sv*head); //Ham sap xep theo ho ten sinh vien
void sapxeptheodiem(sv*head); //Ham sap xep theo diem ki I, ki II, trung binh nam
void in(sv*cur,int i); //Ham in du lieu gom day du thong tin
void in1(sv*cur,int i); //Ham in danh sach sinh vien theo STT va ho ten
void copy(sv*ptr1,sv*ptr2); //Ham copy du lieu giua 2 nut trong danh sach
void swap(sv*ptr1,sv*ptr2); // Ham trao doi noi dung
char*catxau(sv*ptr); //Ham cat xau thanh nhung xau nho
/********************************************************************************************/
int main()
{
sv*ptr;
char wait;
int choice,i=1;
head=(sv*)malloc(sizeof(sv));
if(head==NULL)
{
cout<<"KHONG CAP PHAT DUOC BO NHO, KET THUC CHUONG TRINH";
exit(1);
}
else
{
head->next=head;
head->prev=head;
}
cout<<"\nMOI BAN CHON PHUONG THUC NHAP";
cout<<"\n1. NHAP DU LIEU TU BAN PHIM";
cout<<"\n2. NHAP DU LIEU TU FILE";
cout<<"\n BAN CHON : ";
cin>>choice;
while(choice<1||choice>2)
{
cout<<"\nBAN VUA NHAP KHONG DUNG, HAY NHAP LAI ";
cout<<"\n1. NHAP DU LIEU TU BAN PHIM";
cout<<"\n2. NHAP DU LIEU TU FILE";
cout<<"\n BAN CHON : ";
cin>>choice;
}
switch(choice)
{
case 1:
nhapdulieutubanphim();
break;
case 2:
nhapdulieututep();
break;
}
do
{
cout<<"\n\n"<<"XIN MOI BAN CHON CAC CHUC NANG CUA CHUONG TRINH\n";
cout<<"\n"<<"1. HIEN THI TOAN BO DANH SACH";
cout<<"\n"<<"2. HIEN THI DU LIEU THEO TUNG LOP";
cout<<"\n"<<"3. SAP XEP";
cout<<"\n"<<"4. TIM KIEM";
cout<<"\n"<<" BAN CHON : ";
cin>>choice;
while(choice<1||choice>4)
{
cout<<"\n"<<"BAN VUA CHON CHUC NANG KHONG CO TRONG CHUONG TRINH";
cout<<"\n"<<"XIN MOI CHON LAI";
cout<<"\n"<<"1. HIEN THI TOAN BO DANH SACH";
cout<<"\n"<<"2. HIEN THI DU LIEU THEO TUNG LOP";
cout<<"\n"<<"3. SAP XEP";
cout<<"\n"<<"4. TIM KIEM";
cout<<"\n"<<" BAN CHON : ";
cin>>choice;
}
switch(choice)
{
case 1:
hienthitoandanhsach(head);
break;
case 2:
hienthidulieutheolop(head);
break;
case 3:
sapxep();
break;
case 4:
timkiem();
break;
}
cout<<"\n"<<"BAN CO MUON THUC HIEN TIEP KHONG (y/n)";
wait=getche();
}while(wait=='Y'||wait=='y');
getch();
return 1;
}
/*******************************************************************************/
void nhapdulieutubanphim()
{
char wait;
do
{
nhapdulieutungsvtubanphim(head);
cout<<"\n BAN CO MUON NHAP TIEP KHONG (y/n)";
wait=getche();
}while(wait=='Y'||wait=='y');
}
void nhapdulieututep()
{
FILE*fvao;
fvao=fopen("E:\\dulieusinhvien.in","a+");
if(fvao==NULL)
{
cout<<"\nLOI MO FILE !!!"<<"\n"<<"KET THUC CHUONG TRINH";
exit(1);
}
else
{
while(!feof(fvao))
{
nhapdulieutungsvtutep(head,fvao);
}
}
if(feof(fvao))
cout<<"\nNHAP THANH CONG !!!\n";
fclose(fvao);
}
void nhapdulieutungsvtubanphim(sv *head)
{
char ml[12],hoten[30];
struct sv*temp,*cur;
FILE*f;
temp=(sv*)malloc(sizeof(sv));
if(temp==NULL)
{
cout<<"\nKHONG CAP PHAT DUOC VUNG NHO, KET THUC CHUONG TRINH";
exit(1);
}
else
{
f=fopen("E:\\dulieusinhvien.in","a+");
cout<<"\nNHAP DU LIEU SINH VIEN : \n";
cout<<"\nMA SINH VIEN : ";
scanf("%d",&temp->data.masv);
fprintf(f,"%d ",temp->data.masv);//ghi du lieu len tep
cout<<"MA LOP : ";
fflush(stdin);
cin.get(ml,12);
cin.ignore(80,'\n');
strcpy(temp->data.malop,ml);
fprintf(f,"%s\n",temp->data.malop);
cout<<"HO VA TEN : ";
fflush(stdin);
cin.get(hoten,30);
cin.ignore(80,'\n');
strcpy(temp->data.hovaten,hoten);
fprintf(f,"%s\n",temp->data.hovaten);
cout<<"DIEM KI I : ";
cin>>temp->data.diemk1;
fprintf(f,"%f ",temp->data.diemk1);
cout<<"DIEM KI II : ";
cin>>temp->data.diemk2;
fprintf(f,"%f\n",temp->data.diemk2);
//Noi temp vao danh sach cua head
cur=head->prev;
temp->next=cur->next;
cur->next->prev=temp;
cur->next=temp;
temp->prev=cur;
cout<<"\nNHAP XONG !";
fclose(f);
}
}
void nhapdulieutungsvtutep(sv*head,FILE*f)
{
sv*temp,*cur;
char ml[12],hoten[30];
temp=(sv*)malloc(sizeof(sv));
if(temp==NULL)
{
cout<<"KHONG CAP PHAT DUOC VUNG NHO, KET THUC CHUONG TRINH";
exit(1);
}
else
{
fscanf(f,"%d",&temp->data.masv);
fseek(f,1,SEEK_CUR);//Nhay qua 1 ki tu, trong truong hop nay la nhay qua dau cach nam giua masv va malop
fflush(stdin);
fgets(ml,12,f);
ml[strlen(ml)-1] = '\0';//do ham fgets tu dong gan ki tu '\n' vao
//cuoi xau nen phai thay dau '\n' thanh '\0' tranh cho thuat toan thuc hien sai
strcpy(temp->data.malop,ml);
fflush(stdin);
fgets(hoten,30,f);
hoten[strlen(hoten)-1] = '\0';
strcpy(temp->data.hovaten,hoten);
fscanf( f,"%f", &temp->data.diemk1 );
fscanf( f,"%f", &temp->data.diemk2);
//Noi temp vao danh sach cua head
cur=head->prev;
temp->next=cur->next;
cur->next->prev=temp;
cur->next=temp;
temp->prev=cur;
}
}
void in(sv*cur,int i)
{
if(i==1)
{
cout<<"\n"<<"|STT | MA SV | MA LOP | HO VA TEN |KI 1|KI 2|";
cout<<"\n"<<"|----|----------|------------|------------------------------|----|----|"<<"\n";
}
cout.setf(ios::left); //can le trai
cout<<"|"<<setw(4)<<i<<"|"<<setw(10)<<cur->data.masv<<"|"<<setw(12)<<cur->data.malop<<"|";
cout<<setw(30)<<cur->data.hovaten<<"|"<<setw(4)<<cur->data.diemk1<<"|"<<setw(4)<<cur->data.diemk2<<"|";
cout<<"\n"<<"|----|----------|------------|------------------------------|----|----|"<<"\n";
}
void in1(sv*cur,int i)
{
if(i==1)
{
cout<<"\n"<<"|STT | HO VA TEN |";
cout<<"\n"<<"|----|------------------------------|"<<"\n";
}
cout.setf(ios::left);
cout<<"|"<<setw(4)<<i<<"|"<<setw(30)<<cur->data.hovaten<<"|";
cout<<"\n"<<"|----|------------------------------|"<<"\n";
}
void hienthitoandanhsach(sv*head)
{
sv*ptr;
int i=0;
ptr=head->next;
while(ptr!=head)
{ i++;
in(ptr,i);
ptr=ptr->next;
}
}
void hienthidulieutheolop(sv*head)
{
int i=0,flag=0;
sv*ptr;
char ml[12];
cout<<"\nNHAP MA LOP : ";
fflush(stdin);
cin.get(ml,12);
ptr=head;
ptr=ptr->next;
cout<<"\nDANH SACH LOP :";
while(ptr!=head)
{
if(!strcmp(ptr->data.malop,ml))
{
i++;
in1(ptr,i);
flag=1;
}
ptr=ptr->next;
}
if(flag==0) cout<<"\nMA LOP BAN VUA NHAP KHONG DUNG HOAC LOP KHONG CO SINH VIEN NAO";
}
void sapxep()
{
int choice;
cout<<"\n"<<"XIN MOI BAN CHON CAC CHUC NANG SAP XEP CUA CHUONG TRINH :\n";
cout<<"\n"<<"1. SAP XEP THEO MA SO SINH VIEN";
cout<<"\n"<<"2. SAP XEP THEO HO TEN";
cout<<"\n"<<"3. SAP XEP THEO DIEM";
cout<<"\n BAN CHON : ";
cin>>choice;
while(choice<1||choice>3)
{
cout<<"\nBAN DA CHON CHUC NANG KHONG CO TRONG CHUONG TRINH, XIN MOI CHON LAI :\n";
cout<<"\n1. SAP XEP THEO MA SO SINH VIEN";
cout<<"\n2. SAP XEP THEO HO TEN";
cout<<"\n3. SAP XEP THEO DIEM";
cin>>choice;
}
switch(choice)
{
case 1:
sapxeptheomasv(head);
break;
case 2:
sapxeptheoten(head);
break;
case 3:
sapxeptheodiem(head);
break;
}
}
void sapxeptheomasv(sv*head)
{
sv*ptr1,*ptr2,*min;
ptr1=head;
ptr1=ptr1->next;
while(ptr1->next!=head)
{
min=ptr1;
ptr2=ptr1->next;
while(ptr2!=head)
{
if(ptr2->data.masv<min->data.masv)
{
min=ptr2;
}
ptr2=ptr2->next;
}
swap(ptr1,min);
ptr1=ptr1->next;
}
cout<<"\nDA SAP XEP XONG !";
}
void swap(sv*ptr1,sv*ptr2)
{
sv*temp;
temp=(sv*) malloc(sizeof(sv));
if(temp==NULL)
{
cout<<"\nKHONG CAP PHAT DUOC VUNG NHO, KET THUC CHUONG TRINH";
exit(1);
}
else
{
copy(temp,ptr1);
copy(ptr1,ptr2);
copy(ptr2,temp);
}
free(temp);
}
void copy(sv*ptr1,sv*ptr2)
{
ptr1->data.masv=ptr2->data.masv;
ptr1->data.diemk1=ptr2->data.diemk1;
ptr1->data.diemk2=ptr2->data.diemk2;
strcpy(ptr1->data.malop,ptr2->data.malop);
strcpy(ptr1->data.hovaten,ptr2->data.hovaten);
}
void sapxeptheoten(sv*head)
{
sv*ptr1,*ptr2,*min;
char ten1[30],ten2[30];
ptr1=head;
ptr1=ptr1->next;
while(ptr1->next!=head)
{
min=ptr1;
strcpy(ten1,catxau(min)) ;
ptr2=ptr1->next;
while(ptr2!=head)
{
strcpy(ten2,catxau(ptr2));
if(strcmp(ten1,ten2)>0)
{
min=ptr2;
strcpy(ten1,catxau(min)) ;
}
ptr2=ptr2->next;
}
swap(ptr1,min);
ptr1=ptr1->next;
}
cout<<"\nDA SAP XEP XONG !";
}
char*catxau(sv*ptr)
{
char *xau1;
char xau2[30];
int i=0,j=0,count=0;
strcpy(xau2,ptr->data.hovaten);
//Dem so dau cach
while(xau2[i]!='\0')
{
if(xau2[i]==' ') count++;
i++;
}
xau1=strtok(xau2," ");//cat tu ki tu dau tien den dau cach dau tien cua xau2 luu vao xau1
//sau lenh nay, xau2 se con cac ki tu giong nhu xau1, ta duoc first name
//vong lap nay se tim den xau con sau dau cach cuoi cung trong xau2 ban dau
//roi luu vao xau1, sau vong lap nay ta se cat duoc last name
while(xau1 != NULL)
{
j++;
xau1=strtok(NULL," ");
if(j==count) break;
}
strcat(xau1,xau2); //noi first name vao sau last name de so tao ra xau dem so sanh
return xau1;
}
void sapxeptheodiem(sv*head)
{
sv*ptr1,*ptr2,*max;
int choice;
float diemmax,temp;
cout<<"\n"<<"BAN CAN SAP XEP THEO LOAI DIEM NAO ?\n";
cout<<"\n"<<"1. DIEM KI I";
cout<<"\n"<<"2. DIEM KI II";
cout<<"\n"<<"3. DIEM TRUNG BINH NAM"<<"\n";
cout<<"BAN CHON : ";
cin>>choice;
while(choice<1||choice>3)
{
cout<<"\n"<<"BAN DA CHON CHUC NANG SAP XEP KHONG CO TRONG CHUONG TRINH MOI BAN CHON LAI :"<<"\n";
cout<<"\n"<<"1. DIEM KI I";
cout<<"\n"<<"2. DIEM KI II";
cout<<"\n"<<"3. DIEM TRUNG BINH NAM";
cout<<"\n BAN CHON : ";
cin>>choice;
}
ptr1=head;
ptr1=ptr1->next;
while(ptr1->next!=head)
{
max=ptr1;
if(choice==1)
diemmax=max->data.diemk1;
else if((choice==2))
diemmax=max->data.diemk2;
else
diemmax=(max->data.diemk1+max->data.diemk2)/2.0;
ptr2=ptr1->next;
while(ptr2!=head)
{
if(choice==1)
temp=ptr2->data.diemk1;
else if(choice==2)
temp=ptr2->data.diemk2;
else
temp=(ptr2->data.diemk1+ptr2->data.diemk2)/2.0;
if(temp>diemmax)
{
max=ptr2;
if(choice==1)
diemmax=max->data.diemk1;
else if(choice==2)
diemmax=max->data.diemk2;
else
diemmax=(max->data.diemk1+max->data.diemk2)/2.0;
}
ptr2=ptr2->next;
}
swap(ptr1,max);
ptr1=ptr1->next;
}
cout<<"\nDA SAP XEP XONG !";
}
void timkiem()
{
int choice;
cout<<"\nXIN MOI BAN CHON CAC CHUC NANG TIM KIEM CUA CHUONG TRINH :\n";
cout<<"\n1. TIM KIEM THEO MA SO SINH VIEN";
cout<<"\n2. TIM KIEM THEO HO TEN";
cout<<"\n BAN CHON ";
cin>>choice;
while(choice<1||choice>2)
{
cout<<"\n"<<"BAN DA CHON CHUC NANG KHONG CO TRONG CHUONG TRINH, XIN MOI CHON LAI :\n";
cout<<"\n"<<"1. TIM KIEM THEO MA SO SINH VIEN";
cout<<"\n"<<"2. TIM KIEM THEO HO TEN";
cout<<"\n BAN CHON ";
cin>>choice;
}
switch(choice)
{
case 1:
timtheomasv(head);
break;
case 2:
timtheoten(head);
break;
}
}
void timtheoten(sv*head)
{
char ten[30];
int flag=0,i=0;
sv*ptr;
ptr=head;
ptr=ptr->next;
cout<<"\nNHAP HO TEN SINH VIEN BAN CAN TIM : ";
fflush(stdin);
cin.get(ten,30);
cout<<"\n"<<"THONG TIN SINH VIEN BAN CAN TIM"<<"\n";
while(ptr!=head)
{
if(!strcmp(ptr->data.hovaten,ten))
{
i++;
in(ptr,i);
flag=1;
}
ptr=ptr->next;
}
if(flag==0) cout<<"\nKHONG CO SINH VIEN BAN CAN TIM";
}
void timtheomasv(sv*head)
{
int ma,i=0;
int flag=0;
sv*ptr;
ptr=head;
ptr=ptr->next;
cout<<"\nNHAP MA SO SINH VIEN BAN CAN TIM : ";
cin>>ma;
cout<<"\n"<<"THONG TIN SINH VIEN BAN CAN TIM\n";
while(ptr!=head)
{
if(ptr->data.masv==ma)
{
i++;
in(ptr,i);
flag=1;
}
ptr=ptr->next;
}
if(flag==0) cout<<"\nKHONG CO SINH VIEN BAN CAN TIM";
}
#include <stdio.h>
void main ()
{
float a[8000][8000];
int i,j;
for (i=0;i<8000;i++)
for (j=0;j<8000;j++)
a[j] = 1.5;
}
vector: vector<vector<int>> arrayName;
pointer: int **arrayName;
linked list: blah blah
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int n;
int * a;
a = (int*) malloc (8000*sizeof(int));
for (n=0; n<8000; n++)
a[n]=n;
printf ("Random string: %s\n",a[1]);
free (a);
return 0;
}

xem xem nó segment fault ở đâu.
Bắt buộc phải dùng C à
Mảng bị tràn stack thì thử
static int[x][x] coi
Hoặc ko thì tạo mảng 1 chiều [8k*8k]
Ai copy về xem dùm mình cái này cái h mình muốn an chữ Login rồi dữ liệu nhập vào kia mà ko biết làm<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>THEM SINH VIEN</title>
<script>
<!-- Cau 1-->
function Init()
{
frmnhap.ht.focus()
frmnhap.nh.disabled=true
}
<!---Cau 2-->
function Test()
{
var hten,lop;
hten=frmnhap.ht.value;
lop=frmnhap.lo.value;
if(hten=="")
{
alert("Ban quen nhap ho ten roi")
return;
}
if(lop=="")
{
alert("Ban quen nhap lop roi")
return;
}
frmnhap.nh.disabled=false
}
var count;
count=1;
function WriteData()
{
var hten,lop,mon;
var pdau,pthan,pthem,pcuoi
hten=frmnhap.ht.value;
lop=frmnhap.lo.value;
Idhten.innerHTML=hten
Idlop.innerHTML=lop
Idmon.innerHTML=mon
Idhten.id="Idhten"+count
Idlop.id="Idlop"+count
Idmon.id="Idmon"+count
count++;
pthan=Iddata.innerHTML
pdau="<table id=Iddata border='1' cellpadding=1 cellspacing='1' width='100%' STYLE='border-collapse:collapse'>"
pthem="<tr>"
pthem=pthem+ " <td width=50% id=Idhten style='font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold'> </td>"
pthem=pthem+" <td width=50% id=Idlop style='font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold'> </td>"
pthem=pthem+ " </tr>"
pcuoi="</table>"
Iddata.outerHTML=pdau+pthan+pthem+pcuoi
frmnhap.nh.disabled=true
frmnhap.ht.value=""
frmnhap.lo.value=""
}
</script>
</head>
<body onload=Init()>
<table border="1">
<form method="POST" action="--WEBBOT-SELF--" name="frmnhap">
Họ tên<input type="text" name="ht" size="20"><br></br>
Lớp
<select name="Idlop">
<option value="1" selected="selected">09CDTP2</option>
<option value="2">09CDTP1</option>
<option value="3">09CDTM1</option>
<option value="4">09CDTm2</option></select><br></br>
Môn
<select name="lop">
<option value="1" selected="selected">Anh Văn</option>
<option value="2">Tin học</option>
<option value="3">Triết học</option>
<option value="4">Vật lý</option>
<option value="5">Tóan</option></select>
<br></br>
<td width="26%" style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold" align="right"> </td>
<p>
<input type="radio" name="Gioitinh" onMouseMove=="window.status='Trong nam';">
Lý thuyết</p>
<p>
<input type="radio" name="Gioitinh" onMouseMove=="window.status='Trong nu';">
Thực hành
</td>
</p>
<tr>
<td width="26%" style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold" align="right"></td>
<td width="74%" style="font-family: Tahoma; font-size: 10pt; font-weight: bold"><input type="button" value="Login" onClick="WriteData()" name="nh"></td>
</tr>
<tr>
<td width="100%" style="font-family: Times New Roman; font-size: 14pt; color: #CC3300; font-weight: bold" align="center" colspan="2" bgcolor="#E6FFF9"></td>
</tr>
<tr>
<td width="100%" style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold" align="center" colspan="2">
<table id=Iddata border="1" cellpadding=1 cellspacing="1" width="100%" STYLE="border-collapse:collapse">
<tr>
<td width="50%" style="font-family: Tahoma; font-size: 10pt; font-weight: bold" align="center" >Họ Tên </td>
<td width="50%" id=Idhten style="font-family: Tahoma; font-size: 10pt; font-weight: bold" align="center">Lớp</td>
<td width="50%" id=Idhten style="font-family: Tahoma; font-size: 10pt;font-weight: bold" align="center">Môn học </td> </tr>
<tr>
<td width="50%" id=Idhten style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold"> </td>
<td width="50%" id=Idlop style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold"> </td>
<td width="50%" id=Idmon style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold"> </td>
</tr>
</table>
</form>
</body>
</html>
đây là bài gốc , bài trên tớ đang sửa lại mà chả ra cái j cả<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>THEM SINH VIEN</title>
<script>
<!-- Cau 1-->
function Init()
{
frmnhap.ht.focus()
frmnhap.nh.disabled=true
}
<!---Cau 2-->
function Test()
{
var hten,lop;
hten=frmnhap.ht.value;
lop=frmnhap.lo.value;
if(hten=="")
{
alert("Ban quen nhap ho ten roi")
return;
}
if(lop=="")
{
alert("Ban quen nhap lop roi")
return;
}
frmnhap.nh.disabled=false
}
var count;
count=1;
function WriteData()
{
var hten,lop;
var pdau,pthan,pthem,pcuoi
hten=frmnhap.ht.value;
lop=frmnhap.lo.value;
Idhten.innerHTML=hten
Idlop.innerHTML=lop
Idhten.id="Idhten"+count
Idlop.id="Idlop"+count
count++;
pthan=Iddata.innerHTML
pdau="<table id=Iddata border='1' cellpadding=1 cellspacing='1' width='100%' STYLE='border-collapse:collapse'>"
pthem="<tr>"
pthem=pthem+ " <td width=50% id=Idhten style='font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold'> </td>"
pthem=pthem+" <td width=50% id=Idlop style='font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold'> </td>"
pthem=pthem+ " </tr>"
pcuoi="</table>"
Iddata.outerHTML=pdau+pthan+pthem+pcuoi
frmnhap.nh.disabled=true
frmnhap.ht.value=""
frmnhap.lo.value=""
}
</script>
</head>
<body onload=Init()>
<form method="POST" action="--WEBBOT-SELF--" name="frmnhap">
<table width=100% border="1" cellspacing="1" cellpadding=1 cellspacing="1" STYLE="border-collapse:collapse">
<tr>
<td width="100%" colspan="2" style="font-family: Times New Roman; font-size: 14pt; color: #808000; font-weight: bold" align="center" bgcolor="#E6FFF9">THEM
SINH VIEN</td>
</tr>
<tr>
<td width="26%" style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold" align="right">Họ
tên</td>
<td width="74%" style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold"><input type="text" name="ht" size="20"></td>
</tr>
<tr>
<td width="26%" style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold" align="right">Lớp</td>
<td width="74%" style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold"><input type="text" name="lo" size="20" onblur="Test()"></td>
</tr>
<tr>
<td width="26%" style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold" align="right"></td>
<td width="74%" style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold"><input type="button" value="Nhap" onclick="WriteData()" name="nh"></td>
</tr>
<tr>
<td width="100%" style="font-family: Times New Roman; font-size: 14pt; color: #CC3300; font-weight: bold" align="center" colspan="2" bgcolor="#E6FFF9">DANH
SACH SINH VIEN</td>
</tr>
<tr>
<td width="100%" style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold" align="center" colspan="2">
<table id=Iddata border="1" cellpadding=1 cellspacing="1" width="100%" STYLE="border-collapse:collapse">
<tr>
<td width="50%" style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold" align="center" bgcolor="#E0E0E0">HỌ
TÊN</td>
<td width="50%" style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold" align="center" bgcolor="#E0E0E0">LỚP</td>
</tr>
<tr>
<td width="50%" id=Idhten style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold"> </td>
<td width="50%" id=Idlop style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold"> </td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>

<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>THEM SINH VIEN</title>
<script>
<!-- Cau 1-->
function Init()
{
//frmnhap.ht.focus()
document.getElementById("ht").focus();
document.getElementById("nh").disabled=true
}
<!---Cau 2-->
function Test()
{
var hten,lop;
hten=document.getElementById("ht").value;
lop=document.getElementById("lop").selectedIndex.value;
if(hten=="")
{
alert("Ban quen nhap ho ten roi")
return;
}
document.getElementById("nh").disabled=false
}
var count;
count=1;
function WriteData()
{
var hten,lop,mon;
var pdau,pthan,pthem,pcuoi
hten=document.getElementById("ht").value;
lop=document.getElementById("lop").value;
mon=document.getElementById("mon").value;
document.getElementById("Idhten").innerHTML=hten
document.getElementById("Idlop").innerHTML=lop
document.getElementById("Idmon").innerHTML=mon
document.getElementById("Idhten").id="Idhten"+count
document.getElementById("Idlop").id="Idlop"+count
document.getElementById("Idmon").id="Idmon"+count
count++;
pthan=document.getElementById("Iddata").innerHTML
pdau="<table id=Iddata border='1' cellpadding=1 cellspacing='1' width='100%' STYLE='border-collapse:collapse'>"
pthem="<tr>"
pthem=pthem+ " <td width=50% id='Idhten' style='font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold'> </td>"
pthem=pthem+" <td width=50% id=Idlop style='font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold'> </td>"
pthem=pthem+ "<td width='50%' id='Idmon' name='Idmon' style='font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold'> </td> </tr>"
pcuoi="</table>"
pthan=document.getElementById("Iddata").outerHTML=pdau+pthan+pthem+pcuoi
document.getElementById("nh").disabled=true;
document.getElementById("ht").value="";
document.getElementById("lop").selectedIndex=1;
document.getElementById("mon").selectedIndex=1;
}
</script>
</head>
<body onload=Init()>
<table border="1">
<form method="POST" action="--WEBBOT-SELF--" name="frmnhap">
Họ tên<input type="text" id="ht" name="ht" size="20" onblur="Test()"><br></br>
Lớp
<select id="lop" name="lop">
<option value="09CDTP2" selected="selected">09CDTP2</option>
<option value="09CDTP1">09CDTP1</option>
<option value="09CDTM1">09CDTM1</option>
<option value="09CDTm2">09CDTm2</option></select><br></br>
Môn
<select id="mon" name="mon">
<option value="Anh Văn" selected="selected">Anh Văn</option>
<option value="Tin học">Tin học</option>
<option value="Triết học">Triết học</option>
<option value="Vật lý">Vật lý</option>
<option value="Tóan">Tóan</option></select>
<br></br>
<td width="26%" style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold" align="right"> </td>
<p>
<input type="radio" name="Gioitinh" onMouseMove="window.status='Trong nam';">
Lý thuyết</p>
<p>
<input type="radio" name="Gioitinh" onMouseMove="window.status='Trong nu';">
Thực hành
</td>
</p>
<tr>
<td width="26%" style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold" align="right"></td>
<td width="74%" style="font-family: Tahoma; font-size: 10pt; font-weight: bold"><input type="button" value="Login" onClick="WriteData()" id="nh" name="nh"></td>
</tr>
<tr>
<td width="100%" style="font-family: Times New Roman; font-size: 14pt; color: #CC3300; font-weight: bold" align="center" colspan="2" bgcolor="#E6FFF9"></td>
</tr>
<tr>
<td width="100%" style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold" align="center" colspan="2">
<table id=Iddata border="1" cellpadding=1 cellspacing="1" width="100%" STYLE="border-collapse:collapse">
<tr>
<td width="50%" style="font-family: Tahoma; font-size: 10pt; font-weight: bold" align="center" >Họ Tên </td>
<td width="50%" style="font-family: Tahoma; font-size: 10pt; font-weight: bold" align="center">Lớp</td>
<td width="50%" style="font-family: Tahoma; font-size: 10pt;font-weight: bold" align="center">Môn học </td> </tr>
<tr>
<td width="50%" id="Idhten" style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold"> </td>
<td width="50%" id="Idlop" style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold"> </td>
<td width="50%" id="Idmon" name="Idmon" style="font-family: Tahoma; font-size: 10pt; color: #336699; font-weight: bold"> </td>
</tr>
</table>
</form>
</body>
</html>
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
<style type="text/css">
<!--
.style2 { color: #FFFFFF;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
}
-->
</style>
</head>
<body>
<table width="778" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="55" colspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="251" height="55" valign="top"><img src="images/Logo.gif" width="251" height="55"></td>
<td width="135" valign="top"><a href="Gioi_Thieu.htm"><img src="images/Nut_GioiThieu.gif" width="135" height="55" border="0"></a></td>
<td width="71" valign="top"><a href="Lien_He.htm"><img src="images/Nut_LienHe.gif" width="71" height="55" border="0"></a></td>
<td width="94" valign="top"><img src="images/Nut_ThuongMai.gif" width="94" height="55"></td>
<td width="71" valign="top"><img src="images/Nut_DichVu.gif" width="71" height="55"></td>
<td width="66" valign="top"><img src="images/Nut_DauTu.gif" width="66" height="55"></td>
<td width="90" valign="top"><img src="images/Nut_DuLich.gif" width="90" height="55"></td>
</tr>
</table></td>
</tr>
<tr>
<td width="199" rowspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#6699CC">
<!--DWLayoutTable-->
<tr>
<td height="227" colspan="5" valign="top"><img src="images/LienHe_Hinh.gif" width="199" height="227"></td>
</tr>
<tr>
<td width="25" height="193"></td>
<td width="64"></td>
<td width="10"></td>
<td width="77"></td>
<td width="25"></td>
</tr>
<tr>
<td height="19"> </td>
<td valign="top"><a href="#"><img src="images/english.gif" width="64" height="18" border="0"></a></td>
<td> </td>
<td valign="top"><a href="#"><img src="images/tiengviet.gif" width="77" height="18" border="0"></a></td>
<td></td>
</tr>
<tr>
<td height="11"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table></td>
<td width="549" height="373" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="11" rowspan="3" valign="top"><!--DWLayoutEmptyCell--> </td>
<td width="432" height="39" valign="bottom"><img src="images/LienHe_TieuDe.gif" width="432" height="17"></td>
<td width="76"> </td>
<td width="30"> </td>
</tr>
<tr>
<td height="19" valign="top"><!--DWLayoutEmptyCell--> </td>
<td></td>
<td></td>
</tr>
<tr>
<td height="315" colspan="2" align="left" valign="top"><form action="mailto:[email protected]" method="post" name="form1" onSubmit="MM_validateForm('txthoten','','R','txtdienthoai','','NisNum','txtfax','','NisNum','txtmail','','RisEmail','txtnoidung','','R');return document.MM_returnValue">
<table width="414" border="0">
<!--DWLayoutTable-->
<tr>
<th width="175" scope="row" align="right">Ho ten day du *:</th>
<td colspan="2"> <input name="txthoten" type="text" id="txthoten" size="30" maxlength="20"></td>
</tr>
<tr>
<th scope="row" align="right">Cong ty: </th>
<td colspan="2"><input name="txtcongty" type="text" id="txtcongty" size="30" maxlength="25"></td>
</tr>
<tr>
<th scope="row" align="right">Dia chi: </th>
<td colspan="2"><input name="txtdiachi" type="text" id="txtdiachi" size="30" maxlength="25"></td>
</tr>
<tr>
<th scope="row" align="right">Dien thoai: </th>
<td colspan="2"><input name="txtdienthoai" type="text" id="txtdienthoai" size="15" maxlength="10"></td>
</tr>
<tr>
<th scope="row" align="right">Fax:</th>
<td colspan="2"><input name="txtfax" type="text" id="txtfax" size="15" maxlength="10"></td>
</tr>
<tr>
<th scope="row" align="right">E-mail*:</th>
<td colspan="2"><input name="txtmail" type="text" id="txtmail" size="30" maxlength="25"></td>
</tr>
<tr>
<th scope="row" align="right" valign="top">Noi dung*: </th>
<td colspan="2"><textarea name="txtnoidung" cols="30" rows="5" id="txtnoidung"></textarea></td>
</tr>
<tr>
<th height="21" scope="row"> </th>
<th colspan="2" align="center" valign="top">* Bat buoc</th>
</tr>
<tr>
<th scope="row"> </th>
<td width="124" align="center"><input type="submit" name="Submit" value="Gui di"> </td>
<td width="101"><input type="reset" name="Reset" value="Xoa"></td>
</tr>
</table>
</form></td>
<td> </td>
</tr>
</table></td>
<td width="30"> </td>
</tr>
<tr>
<td height="27" colspan="2" valign="middle"><hr color="#000066"></td>
</tr>
<tr>
<td height="44"> </td>
<td></td>
</tr>
<tr valign="middle" bgcolor="#083C77">
<td height="19" colspan="3"><span class="style2"><marquee loop="0"> Xem tot tren trinh duyet IE 5.0 tro len, do phan giai 800x600 </marquee></span></td>
</tr>
</table>
</body>
</html>
ổng chưa dạy gì cả :( chả hiểu !d nghĩa là cái quái gì nữa
tớ học c và c# r mà đọc cái này chả thấy liên quan j