Rezultati

Up. imeNalogaJezikRezultatČas oddaje
formule-2018 Niz C 100/100OK 19. apr '18 @ 17:32

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 1,488 MiB 0,005 s OK
#2 10/10 1,484 MiB 0,000 s OK
#3 10/10 1,555 MiB 0,004 s OK
#4 10/10 1,555 MiB 0,004 s OK
#5 10/10 1,555 MiB 0,004 s OK
#6 10/10 1,555 MiB 0,004 s OK
#7 10/10 1,555 MiB 0,000 s OK
#8 10/10 1,551 MiB 0,010 s OK
#9 10/10 1,578 MiB 0,004 s OK
#10 10/10 1,555 MiB 0,004 s OK

Ocenjevani program (niz.c):
#include <stdio.h>
#include <string.h>
int main(void)
{
    int size;
    scanf("%d", &size);
    char string[size];
    scanf("%s", string);
    int cnt=0;
    char * point;
    point = strstr(string, "010");
    while (point != NULL)
    {
      int indeks = point-string;
      if (string[indeks +3] == '1')
      {
        string[indeks +2]='1';
        cnt++;
      }
      else if (string[indeks -1] == '1')
      {
        string[indeks] = '1';
        cnt++;
      }
      else 
      {
        string[indeks +1]='0';
        cnt++;
      }
      point = strstr(&string[indeks+3], "010");
    }
    printf("%d\n", cnt);
    return 0;
}