satees 0 Newbie Poster

Four buildings A,B,C ,D
Building1 Build2 ActualDistance AllowedDistance
A B 50 60
A C 40 50
A D 40 35
B C 90 10
B D 78 12
C D 45 50


in this combination if the actual distance is < allowed diatnce then the two buildings will be considered as a single building other wise separate buildings.

AB,AC,CD are < allowed distance.so they are considering as a single buildings.so the display should be
A+B+C+D

Example 2:
Building1 Build2 ActualDistance AllowedDistance
A B 50 60
A C 40 30
A D 40 35
B C 90 10
B D 78 12
C D 45 50

Here AB,CD are considered as single so the display will be
A+B [space ] C+D
Example 3:
Building1 Build2 ActualDistance AllowedDistance
A B 89 60
A C 40 30
A D 40 35
B C 90 10
B D 78 12
C D 45 50

here CD are considered as a single
so the display should be
A [space] B [space] C+D.

This is for 4 buildings.it will be extended to upto n buildings.

i want the logic to display like this in c# .
Thanks for the help