#include using std::cout; using std::cin; typedef struct { double x, y, z; double radius; } sphere; double distance(sphere a, sphere b) { double dist; dist = (a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y) + (a.z - b.z)*(a.z - b.z); return(dist); } main() { sphere bubbles[25]; int i = -1, j, nob = 0; cout << "Enter the radius, x value, y value, and z value of your circles; x, y, and z define the center. When you have entered all of your circles, make the radius and centers 0.\n"; while(bubbles[i].radius != 0) { i++; cin >> bubbles[i].radius >> bubbles[i].x >> bubbles[i].y >> bubbles[i].z; nob++; } cout << " "; for(i = 0; i < nob-1; i++) { cout << i+1 << " "; } cout << "\n"; for(i = 0; i < nob-1; i++) { cout << i+1 << " "; for(j = 0; j < nob-1; j++) { if(i == j) { cout << "- "; continue; } if(distance(bubbles[i], bubbles[j]) < ((bubbles[i].radius)*(bubbles[i].radius) + (bubbles[j].radius)*(bubbles[j].radius))) { cout << "y "; continue; } else if(distance(bubbles[i], bubbles[j]) >= ((bubbles[i].radius)*(bubbles[i].radius) + (bubbles[j].radius)*(bubbles[j].radius))) { cout << "n "; continue; } } cout << "\n"; } cout << "\n"; }