0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    while(cin)
        cin>>x>>y;
        cout<<"YES";

}
  1. here for which input it will print out "YES"?
  2. is cout is logic 1 or 0?
  • 8
    `#include using namespace std;` - *No*, no, no. Don't *ever* do that. – Jesper Juhl Feb 04 '20 at 16:45
  • 2
    https://en.cppreference.com/w/cpp/io/basic_ios/operator_bool – HolyBlackCat Feb 04 '20 at 16:45
  • 2
    @JesperJuhl That comment is not useful as it is now because it does not offer an alternative. It isn't obvious to new developers what these lines do so it isn't obvious what the alternatives are. If you added a link to the questions explaining the problem ([1](https://stackoverflow.com/questions/31816095/why-should-i-not-include-bits-stdc-h) and [2](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice)) it would be allow OP to understand the problem and to know what else they can do instead. Edit : Had the wrong link... – François Andrieux Feb 04 '20 at 17:00
  • 3
    *Please* read [Why should I not #include ?](https://stackoverflow.com/q/31816095/5910058) – Jesper Juhl Feb 04 '20 at 17:01
  • @FrançoisAndrieux I just posted a link to a question that's answered with the *why*. – Jesper Juhl Feb 04 '20 at 17:02

1 Answers1

4

This will print "YES" for any input (except for an infinite stream of valid input, in which case it'll run forever and never print anything).

  1. You forgot braces for your loop, so the cout statement is not actually in the loop.

  2. Your cout is in no way conditional on the values you read in.

Jesper Juhl
  • 30,449
  • 3
  • 47
  • 70