// 解答6.5 distance.c #include #include #include "game.h" #include "board.h" #include "move.h" #include "rule.h" // 配列の要素数 #define CNT(x) (sizeof(x)/sizeof(x[0])) // 距離の計算 // ここでは(x座標の差)+(y座標の差) int getdistance(Point from, Point to) { int dx = from.x - to.x; int dy = from.y - to.y; return abs(dx)+abs(dy); } // テストデータ struct { int expected; Point from, to; } distance_data[] = { 1 , {3, 3}, {3, 4}, 2 , {3, 3}, {4, 4} }; // テスト関数 void test_getdistance() { for (int i=0;i