Advertisement
Josif_tepe

Untitled

Nov 14th, 2023
682
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int rek(int x) {
  4.     int pogolemi = 0, pomali = 0;
  5.     while(x > 0) {
  6.         int cifra = x % 10;
  7.         if(cifra > 4) {
  8.             pogolemi++;
  9.         }
  10.         else {
  11.             pomali++;
  12.         }
  13.         x /= 10;
  14.     }
  15.     if(pogolemi > pomali) {
  16.         return 1;
  17.     }
  18.     else {
  19.         return 2;
  20.     }
  21. }
  22. int main () {
  23.  
  24.     int n;
  25.     scanf("%d", &n);
  26.    
  27.     printf("%d\n", rek(n));
  28.  
  29. return 0;
  30.  
  31. }
  32. // rek(1234) = rek(12) = 1
  33. // rek(12) = 1
  34.  
  35. // rek(12345) = rek(123) = 0
  36.  // rek(123) = rek(1) = 0
  37. // rek(1) = 0
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement