anhkiet2507

CHỮ SỐ CHẴN LẺ 2

Apr 17th, 2021 (edited)
1,642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. const int MAX = 100 ;
  4. int i, chan,le;
  5. long long x;
  6. void NhapMang(long long a[], int n){
  7.     for(i = 0;i < n; ++i){
  8.         scanf("\n%lld", &a[i]);
  9.     }
  10. }
  11.  
  12. void XuatMang(long long a[], int n){
  13.     for(i = 0;i < n; ++i){
  14.         chan = 0;
  15.         le = 0;
  16.         while (a[i]>0){
  17.             x = a[i] % 10;
  18.             a[i] = a[i] / 10;
  19.             if (a[i]%2==0){
  20.                 chan++;
  21.             } else {
  22.                 le ++;
  23.             }
  24.         }
  25.         printf("%d %d \n", le ,chan);  
  26.     }
  27. }
  28. int main()
  29. {
  30.     long long arr[MAX];
  31.     int n;
  32.     do{
  33.         scanf("%d", &n);
  34.         if(n <= 0 || n > MAX){
  35.             return 0;
  36.         }
  37.     }while(n <= 0 || n > MAX);
  38.     NhapMang(arr, n);
  39.     XuatMang(arr, n);
  40. return 0;
  41. }
Add Comment
Please, Sign In to add comment