Rezultati

Up. imeNalogaJezikRezultatČas oddaje
pridnerozice-2017 Hodnik Java 100/100OK 20. apr '17 @ 17:08

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 34,762 MiB 0,000 s OK
#2 10/10 37,887 MiB 0,000 s OK
#3 10/10 37,766 MiB 0,000 s OK
#4 10/10 37,406 MiB 0,000 s OK
#5 10/10 34,883 MiB 0,000 s OK
#6 10/10 32,965 MiB 0,000 s OK
#7 10/10 34,625 MiB 0,000 s OK
#8 10/10 34,008 MiB 0,000 s OK
#9 10/10 39,922 MiB 0,000 s OK
#10 10/10 39,820 MiB 0,000 s OK

Ocenjevani program (Hodnik.java):
import java.util.*;

public class Hodnik{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String st = sc.next();
		String[] niz = st.split("");
		int st1 = 0;
		int st2 = 0;
		for(int i = 0; i < niz.length;i++) {
			if(i%2 == 0) {
				if(niz[i].equals("1")) {
					st1++;
				}
			}
			if(i%2 == 1) {
				if(niz[i].equals("0"))
					st1++;
			}
		}
		for(int j = 0; j < niz.length;j++) {
			if(j%2 == 0) {
				if(niz[j].equals("0")) {
					st2++;
				}
			}
			if(j%2 == 1) {
				if(niz[j].equals("1"))
					st2++;
			}
		}
		System.out.println(Math.min(st1,st2));
	}
}