You are not logged in. Please login at www.codechef.com to post your questions!

×

p;ease guide me what the problem with code

this code generate correct output on all cases that i can think but spoj results "wrong answer" please help me how can i resolve this problem

problem code :ERROR Practise|easy my code:#include<iostream>

#include<string>
using namespace std;
int main()
{
int T;
cin>>T;
if(T>100||T<1)
return 0;
while(T--)
{
string s;
cin>>s;
int l=s.length();
int i=0;
for(;i<(l-2);i++)
{
if(s[i]!='0'&&s[i]!='1')
return 0;
if(((s[i]=='0')&&(s[i+1]=='1')&&(s[i+2]=='0'))||((s[i]=='1')&&(s[i+1]=='0')&&(s[i+2]=='1')))
{cout<<"Good"<<endl;
break;
}
}
if(i==l-2)
cout<<"Bad"<<endl;
}
return 0;
}

asked 23 Jul '17, 21:23

yogi10's gravatar image

5★yogi10
52
accept rate: 0%

edited 23 Jul '17, 23:22

vijju123's gravatar image

5★vijju123 ♦
14.8k11856

Does your code even compile?

(23 Jul '17, 23:23) vijju123 ♦5★

format your code yogi...use the option with a pic of binaries or just edit your question and type < code >(no spaces) at start of your code.

link

answered 23 Jul '17, 21:28

stabcode_77's gravatar image

1★stabcode_77
806
accept rate: 12%

This will help u

link

answered 23 Jul '17, 22:59

drjaat's gravatar image

2★drjaat
267111
accept rate: 6%

edited 23 Jul '17, 22:59

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×2,576

question asked: 23 Jul '17, 21:23

question was seen: 241 times

last updated: 23 Jul '17, 23:45