Rezultati

Up. imeNalogaJezikRezultatČas oddaje
kkrsnik Hodnik Java 100/100OK 20. apr '17 @ 17:18

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 37,805 MiB 0,000 s OK
#2 10/10 32,516 MiB 0,000 s OK
#3 10/10 35,676 MiB 0,000 s OK
#4 10/10 37,742 MiB 0,000 s OK
#5 10/10 34,629 MiB 0,000 s OK
#6 10/10 34,813 MiB 0,000 s OK
#7 10/10 35,945 MiB 0,000 s OK
#8 10/10 29,465 MiB 0,000 s OK
#9 10/10 35,152 MiB 0,000 s OK
#10 10/10 37,945 MiB 0,000 s OK

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

public class Naloga4 {

        public static void main(String[] args){
            Scanner sc=new Scanner(System.in);
            int odg=0;
            String niz = sc.next();
            int dol=niz.length();
            for (int i = 0; i < dol; i++) {
                if(niz.charAt(i)==(i%2==0?'0':'1'))
                    odg++;
            }

            if (odg<=dol/2) {
                System.out.println(odg);
            } else {
                System.out.println(dol-odg);
            }

        }

}