Rezultati

Up. imeNalogaJezikRezultatČas oddaje
zagretivaflji-2017 Hodnik Java 100/100OK 20. apr '17 @ 16:28

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 35,188 MiB 0,000 s OK
#2 10/10 37,695 MiB 0,000 s OK
#3 10/10 35,371 MiB 0,000 s OK
#4 10/10 34,078 MiB 0,000 s OK
#5 10/10 38,051 MiB 0,000 s OK
#6 10/10 34,887 MiB 0,000 s OK
#7 10/10 36,273 MiB 0,000 s OK
#8 10/10 37,926 MiB 0,000 s OK
#9 10/10 35,996 MiB 0,000 s OK
#10 10/10 35,367 MiB 0,000 s OK

Ocenjevani program (Naloga1.java):
import java.util.Scanner;

public class Naloga1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String niz = sc.next();

        int length = niz.length();
        int st1 = 0;
        int st2 = 0;

        for (int i = 0; i < length; i++) {
            if (i % 2 == 0) {
                if (niz.charAt(i) == '0')
                    st1++;
                else
                    st2++;
            } else {
                if (niz.charAt(i) == '0')
                    st2++;
                else
                    st1++;
            }
        }

        System.out.println(Math.min(st1, st2));
    }
}