How to write code to realize the effect of moving distance
This article mainly introduces "how to write code to achieve mobile distance effect". In daily operation, I believe that many people have doubts about how to write code to achieve mobile distance effect. I have consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts of "how to write code to achieve mobile distance effect"! Next, please follow the editor to study!
Manhattan distance-broken line distance
Euclid distance-straight line distance
A two-dimensional array of serpentine storage, with row numbers / width, column numbers with% width and special judgment on even rows.
# include#include#include#includeusing namespace std;int wrecovernlemint main () {cin > > w > > m > n; / / in order to avoid the special order of division, subtract the number of each building by 1m, and / or subtract the number of buildings by 1m; / / the line number, int x1qmdebar, x2cm; / / column number (serpentine-even rows) int y1% wpary2% w; if (x1% 2) If (x2% 2) y2 cout