Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // КН-15 лр9вар9.cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- #include <stdlib.h>
- #include <iostream>
- #include "conio.h"
- #include "time.h"
- #pragma warning(disable: 4996)
- int main()
- {
- setlocale(LC_ALL, "Russian");
- srand(time(NULL));
- float x[300], y[300], r[300];
- int max = 0;
- int m;
- int count = 0;
- float d;
- printf("Количество окружностей \n");
- scanf("%d", &m);
- for (int i = 0; i < m; i++)
- {
- x[i] = (rand() % 300) / 10.0;
- y[i] = (rand() % 300) / 10.0;
- r[i] = 5+ rand() % 100 /10.0;
- }
- for (int i = 0; i < m-1; i++)
- {
- d = sqrt(powf(x[i + 1] - x[i], 2) + powf(y[i + 1] - y[i], 2));
- if (d < (r[i] + r[i + 1])) count++;
- else if (count>max) { max = count; count = 0; }
- else count = 0;;
- }
- printf("\n___________\n");
- printf("X Y r\n");
- printf("___________\n");
- for (int i = 0; i < m; i++)
- printf("%.1f %.1f %.1f\n", x[i], y[i],r[i]);
- printf("\nСамая длинная цепочка из %d окружностей", max);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment