Task: Given a file containing information about the circles (radius and center coordinates). Rewrite all circles in file G, i.e. circles that do not intersect with other circles. Implement on binary files using data structures (struct). In general, writing to the file and reading from it did not cause any difficulties. But I still think it is more rational to check the circles for intersection in the array
FILE f, g;
struct Round { double X,Y; double radius; }; Round UED(Round x1,Round x2,Round y1,Round y2,Round r1,Round r2) { Round len.radius= sqrt((x2.X - x1.X) * (x2.X - x1.X) + (y2.Y - y1.Y) * (y2.Y -y1.Y)); if (len.radius > r1.radius + r2.radius) return len; } void main() { system("color F0"); setlocale(LC_ALL,"Russian"); int n; printf("Введите количество окружностей: "); scanf("%d",&n); if(n<2) printf("Это не о чём не говорит\n"); Round O; f=fopen("data.okr","wb"); for(int i=0;i<n;i++) { printf("Введите координаты центра окружности: "); scanf("%lg%lg",&O.X,&O.Y); printf("Введите длину радиуса окружности: "); scanf("%lg",&O.radius); fwrite(&O,sizeof(Round),1,f); } printf("Данные внесены\n"); fclose(f); Round *okr; okr=new Round[n]; int i=0; fopen("data.okr","rb"); while(true) { fread(&okr[i],sizeof(Round),1,f); if(feof(f)) break; printf("\nкоординаты центра окружности: %lg\t %lg ",okr[i].X,okr[i].Y); printf(" \nдлина радиуса окружности: %lg",okr[i].radius); i++; } fclose(f); _getch(); } At the request of the teacher data in the function
Round UED (Round x1, Round x2, Round y1, Round y2, Round r1, Round r2) {Round len.radius = sqrt ((x2.X - x1.X) * (x2.X - x1.X) + ( y2.Y - y1.Y) * (y2.Y -y1.Y)); if (len.radius> r1.radius + r2.radius) return len; } Should be fed through an array, not that 3 cycles to start ???
Roundstructure there is both a radius and both coordinates of the center. - VladD