Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why can't the output go right #1

Open
Irene-Ren opened this issue Aug 18, 2018 · 1 comment
Open

Why can't the output go right #1

Irene-Ren opened this issue Aug 18, 2018 · 1 comment

Comments

@Irene-Ren
Copy link

#include
using namespace std;
bool b[105];
int main(){
int n,m,x,y;
cin>>n>>m;
b[0]=1;
for(int i=1;i<=n;i++){
cin>>x>>y;
for(int j=x+1;j<=y;j++) {
b[j]=1;

	}
**_cout<<b[i]<<" ";_**
}
int w=0;
for(int i=0;i<=m;++i)
	if(b[i]==0) w=1;
if(w)
	cout<<"NO"<<endl;
else
	cout<<"YES"<<endl;
return 0;	

}`

The bolded part is meant to be the testing row to see how the whole program works during compiling,it was expected to output the queue from 0 to n,however, it can only output a '1'.Please help if you know where the bug is,thanks!

@philipxyc
Copy link

philipxyc commented Aug 18, 2018

The goal of the 'cout' testing code is not clear. Its output depends on how many teleports there are (represented by n), more specifically, it will out put b[1:n], but I think what you want is b[0:m].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants