of 50/50
Bam Mo #include <stdio.h> #include <conio.h> /*--------Phan khai bao---------*/ const int B=6; typedef int infor; struct element { infor data; element *next; }; typedef element *List; List A[B]; /*--------Phan dinh nghia ham-----*/ //--------------------------------- //Ham kiem tra so nguyen to int kt_ngto(int x) { int i=1; if(x>1) { do i++; 1

Phan Tich Va Thiet Ke Thuat Toan

  • View
    37

  • Download
    6

Embed Size (px)

Text of Phan Tich Va Thiet Ke Thuat Toan

Bam Mo #include #include /*--------Phan khai bao---------*/ const int B=6; typedef int infor; struct element { infor data; element *next; }; typedef element *List; List A[B]; /*--------Phan dinh nghia ham-----*/ //--------------------------------//Ham kiem tra so nguyen to int kt_ngto(int x) { int i=1; if(x>1) { do i++; while((x%i)!=0); if(x==i) return 1;1

else return 0; } else return 0; } //---------------------------------//Ham bam int h(int x) { int du,kq; du=x%10; switch(du) { case 1:kq=0;break; case 2:kq=1;break; case 3:kq=2;break; case 5:kq=3;break; case 7:kq=4;break; case 9:kq=5;break; } return kq; } //-------------------------//Ham lam rong bang bam void rong()2

{ int i; for(i=0;i=0) printf("\n Tim thay phan tu trong lop thu %d cua bang bam ",i); else printf("\n Khong tim thay phan tu trong bang bam"); printf("\n Press A key to continue..."); getch(); break; case 3 : printf("\n Ban muon them phan tu :"); scanf("%c",&t); InsertClose(t,A); printf("\n Press A key to continue..."); getch();11

break; case 4 : printf("\n Ban muon xoa phan tu :"); scanf("%c",&t); Delete(t,A); printf("\n Press A key to continue..."); getch(); break; case 5 : exit(0); break;

} } } // Cac chuong trinh con int Hash(char x) { int i=x; return (i%10); } void Create(infor A[]) {

int i,j; infor p='a';12

// Khoi tao bang bam for(i=0;i