Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<ctype.h>
- #include"D:\lib\alistlib.h"
- int DemNguyenAm(List &L){
- Position p=First(L);
- int dem=0;
- int nguyenam[]={'A','E','O','U','I'};
- for(int i=0;i<L.Last;i++){
- for(int j=0;j<5;j++)
- if(toupper(L.Elements[i])==nguyenam[j])
- dem++;
- }
- return dem;
- }
- bool giamdan(List &L){
- for(int i=0; i<L.Last;i++){
- if(toupper(L.Elements[i])<toupper(L.Elements[i-1])){
- return 0;
- }
- else return 1;
- }
- }
- void Readlist(List &L){
- ElementType x;
- int n;
- printf("Nhap vao so phan tu cua danh sach: "); scanf("%d",&n);
- for(int i=1;i<=n;i++){
- printf("\nPhan tu thu %d: ",i); fflush(stdin); scanf("%c",&x);
- Insert_List(x,EndList(L),&L);
- }
- }
- main(){
- List L;
- MakeNull_List(&L);
- Readlist(L);
- printf("\nDanh sach co %d nguyen am.", DemNguyenAm(L));
- if(giamdan(L)){
- printf("\nDanh sach giam dan.");
- }else printf("\nDanh sach khong giam.");
- getch();
- }
Add Comment
Please, Sign In to add comment