CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Jan 2020
    Posts
    5

    Please help me with the error.

    The code prints the same output "NO" every time. Please someone help me with what the error can be.
    Code:
    #include<iostream>
    using namespace std;
    
    int main() 
    {
    	int n,q,i,j;
    	int a,b,c,d;
    	cin >> n >> q;
    	int ar[n];
    	for(j=0;j<n;j++)
    	{
    	     cin >> ar[j];
    	}
    	for(i=0;i<q;i++)
    	{
    	     int l,r;
    	     cin >> l >> r;
    	     ar[l-1]=a;
    	     ar[l]=b;
    	     ar[r-2]=c;
    	     ar[r-1]=d;
    	     
    	     if(a<b)
    	     {
    	          if(c>d)
    	          {
    	               cout << "YES" << endl;
    	          }
    	          else 
    	          {
    	               cout << "NO" << endl;
    	          }
    	     }
    	     else
    	     {
    	          if(c<d)
    	          {
    	               cout << "YES" << endl;
    	          }
    	          else 
    	          {
    	               cout << "NO" << endl;
    	          }
    	     }
    
    	 } 
    	 return 0;
    }
    Last edited by VictorN; January 10th, 2020 at 04:33 AM. Reason: added code tags

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured