Update main.cpp

added dist function which gets the distance between two fields