+ 2

Ckeck if three numbers of 4 digit numer are same

So guys, Can I check all condition in one IF CONDITION? #include <iostream> using namespace std; int main() { int n,b,a,c,d; cin>>n; a=n/1000; b=(n/100)%10; c=(n/10)%10; d=n%10; if((a==b && b==c) || (a==c && c==d) || (a==b && b==d) || (b==c && c==d)) cout << " Yes" << endl; else cout << "NO" << endl; return 0; }

30th Nov 2017, 12:08 PM
gogamid
4 Antworten
+ 11
I think you just did it in the code.
30th Nov 2017, 12:11 PM
qwerty
qwerty - avatar
+ 11
Yes.
30th Nov 2017, 12:15 PM
qwerty
qwerty - avatar
+ 3
so is it ok to write like that?
30th Nov 2017, 12:15 PM
gogamid
+ 3
I'm new here, So don't mind if I asked a stupid question :D
30th Nov 2017, 12:17 PM
gogamid