Source Code
#include<iostream>
using namespace std;

int main (){
int nh=0;
  int mid;
  for(int i=0; name[i]!='\0';i++){
    size++;
  }
  if(name[0]==0&&size==1){
    cout<<0;
    exit(0);
    }
  if(name[0]==1&&size==1)
  {
    cout<<'1';
    exit(0);
  }
  for(int i=0;i<size;i++){
      if(name[i]=='1')nh++;
  }
  if(size==2){ 
    cout<<nh;
  }
  else{
   for(int i=1;i<size-1;i++){
    if(name[i]=='0'&&name[i+1]=='1'&&name[i-1]=='1')
      nh++;
    }
   cout<<nh;
  }
  return 0;

    
 }
Copy
Japanese holidays moataz-ghassan
GNU G++17
0 ms
0 KB
Compilation Error