#include <iostream> #include <cmath> using namespace std; int main () { int a, b, c, d; while (cin >> a >> b >> c >> d, a) { if (a==c && b==d) cout << 0 << endl; else if ( abs(a-c)==2 && abs(b-d)==2 || (a==c) || (b==d) ) cout << 1 << endl; else cout << 2 << endl; } return 0; }
#include #include using namespace std; int main () { int a, b, c, d; while (cin >> a >> b >> c >> d, a) { if (a==c && b==d) cout << 0 << endl; else if ( abs(a-c)==2 && abs(b-d)==2 || (a==c) || (b==d) ) <<------------- bad logic cout << 1 << endl; else cout << 2 << endl; } return 0; }
bad logic at the line indicated.