Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include"D:\lib\plistlib.h"
- #include<ctype.h>
- void NHAP(List *L){
- ElementType x;
- printf("\nNhap ky tu, nhap @ de dung!");
- do{
- printf("\nNhap x= "); fflush(stdin);
- scanf("%c",&x);
- if('A'<=x && x<='z' ){
- Position p=First(*L);
- while(p->Next!=NULL&&toupper(p->Next->Element)<toupper(x))
- p=p->Next;
- Insert_List(x,p,L);
- }
- else if (x!='@')
- printf("\nNhap lai");
- }while(x!='@');
- }
- void XOA(List *L){
- Position p=First(*L);
- while(p!=EndList(*L)){
- Position q=p->Next;
- while(q!=EndList(*L))
- if(toupper(p->Next->Element)==toupper(q->Next->Element))
- Delete_List(q,L);
- else q=q->Next;
- p=p->Next;
- }
- }
- int DEM(List L){
- Position p=First(L);
- int dem=0;
- while(p!=EndList(L)){
- dem++;
- p=p->Next;
- } return dem;
- }
- int demm(ElementType x, List L){
- int dem=0;
- Position q=First(L);
- while(q!=EndList(L)){
- if(x==Retrieve(q,L))
- dem++;
- q=q->Next;
- }return dem;}
- ElementType LonNhat(List L, int *Soluong){
- Position p=First(L);
- ElementType Max=Retrieve(First(L),L);
- while(p!=EndList(L)){
- if(Max<Retrieve(p,L)){
- Max=Retrieve(p,L);
- }p=p->Next;
- } printf("\nPhan tu lon nhat la: %c",Max);
- printf("\nSo luong phan tu lon nhat: %d\n", demm(Max,L));
- }
- main(){
- int x;
- List L;
- MakeNull_List(&L);
- NHAP(&L);
- Print_List(L);
- printf("\nSo phan tu trong ds: %d",DEM(L));
- LonNhat(L,&x);
- printf("\nDanh sach sau khi xoa phan tu trung nhau: ");
- XOA(&L);
- Print_List(L);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement