Rezultati

Up. imeNalogaJezikRezultatČas oddaje
mmj-2017 Hodnik C++ 100/100OK 20. apr '17 @ 16:34

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 3,055 MiB 0,004 s OK
#2 10/10 3,109 MiB 0,004 s OK
#3 10/10 3,109 MiB 0,004 s OK
#4 10/10 3,121 MiB 0,004 s OK
#5 10/10 3,117 MiB 0,004 s OK
#6 10/10 3,113 MiB 0,004 s OK
#7 10/10 3,109 MiB 0,004 s OK
#8 10/10 3,117 MiB 0,004 s OK
#9 10/10 3,125 MiB 0,004 s OK
#10 10/10 3,117 MiB 0,004 s OK

Ocenjevani program (main.cpp):
#include <iostream>
#include <string>
using namespace std;

int main()
{
    string s,p;
    cin >> s;
    p = s;
    int a,b,c,d,e;
    a = 0;
    b = 0;
    for (int i = 0; i < s.length();i++){
        if (s[i] == '0'){
            if (i % 2 == 0)a++;
            else b++;
        }
        else {
            if (i%2 == 0) b++;
            else a++;
        }
    }
    if (a > b){
        a = b;
    }
    cout << a;
    return 0;
}