#include <iostream>
using namespace std;

#define sqr(x) x * x
// #define MAX(a, b, c) ((a) >= (b)) ? (c) = (a) : (c) = (b); 
#define MAX(x, y, r) {typeof(x) _x = x; typeof(y) _y = y; \
        (r) = (_x >= _y ? _x : _y);}


void sum();
void out_stream();
void in_stream();
void in_stream_get();
int power(int x, unsigned p);


int main()
{
    std::cout << "Hello, World!\n";
    int c = 0;
    // sum();
    // out_stream();
    // in_stream();
    // in_stream_get();

#if 0
    int ret = power(5, 2);
    std::cout << "res = " << ret << "\r\n";
    ret = power(5, 0);
    std::cout << "res = " << ret << "\r\n";
#endif

    // std::cout << sqr(3 + 0) << "\r\n";
    MAX(4, 6, c);
    std::cout << c << "\r\n";

    return 0;
}

//
void sum()
{
    int a = 0;
    int b = 0;

    cout << "Enter a and b: ";
    cin >> a >> b;
    cout << "a + b = " << (a + b) << endl;
}

// in/out streams
void out_stream()
{
    int i = 42;
    double d = 3.14;
    const char *s = "C-style string";

    std::cout << "This is integer " << i << "\r\n";
    std::cout << "This is double " << d << "\r\n";
    std::cout << "This is a \"" << s << "\"\n";
}

void in_stream()
{
    int i = 42;
    double d = 3.14;

    std::cout << "Enter an integer and a double:\r\n";
    std::cin >> i >> d;
    std::cout << "Your input is " << i << ", " << d << "\r\n";
}

void in_stream_get()
{
    char c = '\0';
    while (std::cin.get(c)) {
        if (c != 'a')
            std::cout << c;
        else break;
    }
}

int power(int x, unsigned p)
{
    return (!p) ? 1 : x * power(x, p - 1);
}


