nguyen_nhan

de1

Oct 18th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<ctype.h>
  4. #include"D:\lib\alistlib.h"
  5. int DemNguyenAm(List &L){
  6.  Position p=First(L);
  7.  int dem=0;
  8.  int nguyenam[]={'A','E','O','U','I'};
  9.     for(int i=0;i<L.Last;i++){
  10.         for(int j=0;j<5;j++)
  11.             if(toupper(L.Elements[i])==nguyenam[j])
  12.             dem++;
  13.     }
  14.     return dem;
  15. }
  16. bool giamdan(List &L){
  17.    for(int i=0; i<L.Last;i++){
  18.     if(toupper(L.Elements[i])<toupper(L.Elements[i-1])){
  19.          return 0;
  20.     }
  21.  
  22.     else return 1;
  23.  
  24.    }
  25. }
  26. void Readlist(List &L){
  27.     ElementType x;
  28.     int n;
  29.     printf("Nhap vao so phan tu cua danh sach: "); scanf("%d",&n);
  30.         for(int i=1;i<=n;i++){
  31.             printf("\nPhan tu thu %d: ",i); fflush(stdin); scanf("%c",&x);
  32.                 Insert_List(x,EndList(L),&L);
  33.         }
  34. }
  35. main(){
  36.     List L;
  37.     MakeNull_List(&L);
  38.     Readlist(L);
  39.     printf("\nDanh sach co %d nguyen am.", DemNguyenAm(L));
  40.     if(giamdan(L)){
  41.         printf("\nDanh sach giam dan.");
  42.     }else printf("\nDanh sach khong giam.");
  43. getch();
  44. }
Add Comment
Please, Sign In to add comment