Advertisement
Josif_tepe

Untitled

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