The C Puzzle Book: Operators 1: Basic Arthmetic Operations
https://qiita.com/kaizen_nagoya/items/2a0d8277d72bfc579df6
のC++版
puzzle_op1.cpp
// The C Puzzle Book, Alan R. Feure, Printice Hall inc.
// Operators 1: Basic Arthmetic Operations
// https://qiita.com/kaizen_nagoya/items/2a0d8277d72bfc579df6
// Dr. Kiyoshi Ogawa
#define CPP
#ifdef CPP
#include <iostream>
using namespace std;
#else
#include <stdio.h>
#include <stdlib.h>
#endif
int main(void)
{
int x;
#ifdef CPP
std::cout << "CPP\n";
x = -3 + 4 * 5 - 6; std::cout << x << "\n"; //Chapter1.1)
x = 3 + 4 % 5 - 6 ; std::cout << x << "\n"; //Chapter1.2)
x = -3 * 4 % - 6 / 5; std::cout << x << "\n"; //Chapter1.3)
x = ( 7 + 6 ) % 5 / 2; std::cout << x << "\n"; //Chapter1.4)
#else
printf("C\n");
x = -3 + 4 * 5 - 6; printf("%d\n",x); //Chapter1.1)
x = 3 + 4 % 5 - 6 ; printf("%d\n",x); //Chapter1.2)
x = -3 * 4 % - 6 / 5; printf("%d\n",x); //Chapter1.3)
x = ( 7 + 6 ) % 5 / 2; printf("%d\n",x); //Chapter1.4)
#endif
return EXIT_SUCCESS;
}