0

Our homework is to compare N circles with each other if they are intersecting or containing.My C file for that is :

```
int N=0 , i=0, j, a=0, max=0;
float circle[MAX] [3] ;
float durum1, durum2, durum3;
float intersection[MAX], containment[MAX];
printf("Please enter the number of circles you want to compare : \n");
scanf ("%d", &N);
for(i=0; i<N; i++)
{
printf ("Enter the values of x, y and r for circle %d: \n", i+1);
scanf ("%f %f %f", &circle[i] [0],&circle[i] [1],&circle[i] [2] );
}
/*intersection situation*/
for(i=0; i<N; i++){
for (j=i+1; j<N; j++){
durum1 =sqrt(((circle[i][0]-circle[j][0])*(circle[i][0]-circle[j][0]))+ ((circle[i][1]-circle[j][1])*(circle[i][1]-circle[j][1])));
durum2 =(circle[i][2]+circle[j][2]);
if ((durum1 <= durum2) && (durum1 != 0)) {
intersection[i] = intersection[i] + 1;
intersection[j] = intersection[j] + 1;}
} }
/*end of intersection*/
/*containment situation*/
for(i=0; i<N; i++){
for (j=0; j<N; j++){
durum1 =sqrt(((circle[i][0]-circle[j][0])*(circle[i][0]-circle[j][0]))+ ((circle[i][1]-circle[j][1])*(circle[i][1]-circle[j][1])));
durum3 =(circle[i][2])-(circle[j][2]);
if ((durum1 <= durum3) && (i!=j)){
containment[i]=containment[i] + 1;}
}
}
/*end of containment*/
/*Print*/
for(i=0; i<N; i++){
if (intersection[i]==0.0){printf("Circle #%d has no intersection",i+1);}
printf("Circle #%d intersects with %0.f circle \n", i+1, intersection[i]);
}
for(i=0; i<N; i++){
if (containment[i]==0.0){printf("Circle #%d has no containment \n",i+1);} else {
printf("Circle #%d contains %0.f circle \n", i+1, containment[i]);}
}
/*End of print*/
```

At the bottom, in the printing section i wanted it to write some explanations instead of "0" circle text if containment*==0.0 or intersection ==0.0. As you see below at intersection part it didn't happen. Containment was much more interesting i believe. It did wrote what i wanted but only for last 2 circles. I believe i did something wrong while writing int or float. I need your help immediately. Thank you very much.*