Advertisement
Josif_tepe

Untitled

Nov 22nd, 2023
845
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. int main() {
  5.     int n;
  6.     scanf("%d", &n);
  7.     int prethoden = 0;
  8.     int brojac = 0;
  9.     for(int i = 0; i < n; i++) {
  10.         int x;
  11.         scanf("%d", &x);
  12.  
  13.         if(prethoden != 0) {
  14.             if(prethoden % 2 == 0 && x % 2 == 0) {
  15.                 brojac++;
  16.             }
  17.             else if(prethoden % 2 == 1 && x % 2 == 1) {
  18.                 brojac++;
  19.             }
  20.         }
  21.         prethoden = x;
  22.  
  23.     }
  24.     printf("%d\n", brojac);
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement