Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 1,457 MiB 0,005 s OK
#2 10/10 1,414 MiB 0,005 s OK
#3 10/10 1,453 MiB 0,000 s OK
#4 10/10 1,418 MiB 0,000 s OK
#5 10/10 1,457 MiB 0,005 s OK
#6 10/10 1,418 MiB 0,000 s OK
#7 10/10 1,414 MiB 0,005 s OK
#8 10/10 1,418 MiB 0,000 s OK
#9 10/10 1,457 MiB 0,005 s OK
#10 10/10 1,457 MiB 0,005 s OK

Ocenjevani program (hodnik.c):
#include <stdio.h>

int main(int argc, char **argv)
{
    int i=0;

    int diff_10 = 0;
    int diff_01 = 0;

    char input = 0;
    
    while(scanf("%c", &input) == 1)
    {
        if(i % 2 == 0)
        {
            //first
            if(input == '1')
            {
                diff_01++;
            }
            else if(input == '0') 
            {
                diff_10++;
            }
        } 
        else
        {
            //first
            if(input == '0')
            {
                diff_01++;
            }
            else if(input == '1') 
            {
                diff_10++;
            }
        }
        
        i++;
    }
    
    int min = diff_10 < diff_01 ? diff_10 : diff_01;
    
    printf("%d\n", min);

    return 0;
}