78_side_effect.sy 540 Bytes
Newer Older
龚平's avatar
龚平 committed
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

int a = -1, b = 1;

int inc_a()
{
    int b = a;
    b = b + 1;
    a = b;
    return a;
}

int main()
{
    int k = 5;
    while (k >= 0) {
        if (inc_a() && inc_a() && inc_a()) {
            putint(a); putch(32); putint(b); putch(10);
        }
        if (inc_a() < 14 || inc_a() && inc_a() - inc_a() + 1) {
            putint(a); putch(10);
            b = b * 2;
        } else {
            inc_a();
        }
        k = k - 1;
    }
    putint(a); putch(32); putint(b); putch(10);
    return a;
}