language: C++11 (gcc-4.7.2)
date: 165 days 0 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
 
bool logic_a(double a, double b, double c, double d)
{
    return !((a>b&&c>d)||(a<b&&c<d));
}
 
bool logic_b(double a, double b, double c, double d)
{
    return (a>=b&&c<=d)||(a<=b&&c>=d)||(a==b)||(c==d);
}
 
int main()
{
    int num_failures = 0;
    double a,b,c,d;
    for (int i=-1; i<=1; ++i)
    {
        a = i;
        for (int j=-1; j<=1; ++j)
        {
            b = j;
            for (int k=-1; k<=1; ++k)
            {
                c = k;
                for (int l=-1; l<=1; ++l)
                {
                    d = l;
                    if (logic_a(a,b,c,d) != logic_b(a,b,c,d))
                    {
                        std::cout << "failed with:\n";                    
                        std::cout << "  a = " << a << '\n'
                                  << "  b = " << b << '\n'
                                  << "  c = " << c << '\n'
                                  << "  d = " << d << "\n\n";
                        ++num_failures;
                    }
 
                }
            }
        }
    }
    
    std::cout << num_failures << " failures\n";
    
}