Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int rek(int x) {
- int pogolemi = 0, pomali = 0;
- while(x > 0) {
- int cifra = x % 10;
- if(cifra > 4) {
- pogolemi++;
- }
- else {
- pomali++;
- }
- x /= 10;
- }
- if(pogolemi > pomali) {
- return 1;
- }
- else {
- return 2;
- }
- }
- int main () {
- int n;
- scanf("%d", &n);
- printf("%d\n", rek(n));
- return 0;
- }
- // rek(1234) = rek(12) = 1
- // rek(12) = 1
- // rek(12345) = rek(123) = 0
- // rek(123) = rek(1) = 0
- // rek(1) = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement